由于网站要开设图片专版,需要用到这个代码(很棒的说):
<?php if($this->category == "分类缩略名"): ?>
<?php $this->need('archive1.php'); ?>
<?php else: ?>
<?php $this->need('archive2.php'); ?>
<?php endif; ?>
当然你也可以用post页面,的确很棒!
由于网站要开设图片专版,需要用到这个代码(很棒的说):
<?php if($this->category == "分类缩略名"): ?>
<?php $this->need('archive1.php'); ?>
<?php else: ?>
<?php $this->need('archive2.php'); ?>
<?php endif; ?>
当然你也可以用post页面,的确很棒!
注:以下常用的模板调用代码均来自TYPECHO各位前辈老师,本站只是整理归档而已。
1.自定义一下标题,以下为代码和参考案例:
<?php if($this->_currentPage>1) echo '第 '.$this->_currentPage.' 页 - '; ?><?php $this->archiveTitle('', '', ' - '); ?><?php $this->options->title(); ?>
<?php if($this->is('index')): ?> - 自定义关键词<?php endif; ?>
这里介绍的方法可以将两个Typecho博客合二为一,包括文章、评论、标签分类都一个不漏:
1.这里假设我们要把B博客的数据合并到A博客里去。首先把B博客的整个数据库导出作为备份,以防出事。
只首页只第一篇文章样式显示不一样,可以用以下判断:
<?php if (($this->_currentPage == 1) && ($this->sequence == 1)): ?>
... //首页第一篇文章
<?php else: ?>
... //其它文章
<?php endif; ?>
判断第一篇文章:
把下面内容添加到 header.php 中 前面
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> <!--如果主题已经引用了jQuery库,可以忽略这条-->
<link rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.2/jquery.fancybox.min.css">
<script src="https://cdn.staticfile.org/fancybox/3.5.2/jquery.fancybox.min.js"></script>
打开post.php,将
<?php $this->content(); ?>
修改成
<?php
$pattern = '/\<img.*?src\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="'.$this->title.'" title="点击放大图片"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
echo $content;
?>
把下面js添加到 footer.php 文件的
前
<script type="text/javascript">
$(document).ready(function () {
$( ".fancybox").fancybox();
});
</script>
完成。