Loading... <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">typecho是一款不错的php博客系统,轻便而功能完备,也有许多的支持者;但博客除了后台功能外,最重要的应该算得上是博客外观了,可是别人所作的模版一般都不大可能完全符合自己的使用习惯、或是品味。我们有必要自己制作、或者至少:能够对已有的模版进行一些个性化的定制,那么,下面的这些小小的技巧也就是必不可少的了。你可以用它们对typecho模版进行一些人性化、个性化的改进。</p> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">1,文章title设置</h3> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">使得对搜索引擎足够友好<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />示例一:<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />首页-- 名称 - 描述 - 归档 - 日期 - 名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />文章-- 标题 - 博客 - 页面 - 标题 - 名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />分类-- 分类 - 博客 - 标签 - 标签 - 名称</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><title> <?php if($this->is('index')): ?><?php $this->options->title(); ?>-<?php $this->options->description(); ?> <?php elseif($this->is('archive')): ?><?php $this->archiveTitle('/','',' - '); ?><?php $this->options->title(); ?> <?php else: ?><?php $this->archiveTitle('','',' - '); ?><?php $this->options->title(); ?><?php endif; ?> </title> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">示例二:<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />首页: 博客名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />页面:页面标题 - 博客名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />分类:分类名称 - 博客名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />标签:标签 - 博客名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />存档:存档: XXXX/XX - 博客名称<br style="margin: 0px; padding: 0px; outline: 0px; border: 0px;" />其它:(日志页)页面标题</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><title> <?php if ($this->is('index')){$this->options->title();} elseif($this->is('page')){$this->archiveTitle('','',' - ');$this->options->title();} elseif($this->is('category')){$this->archiveTitle('','',' - ');$this->options->title();} elseif($this->is('tag')){$this->archiveTitle('','Tag: ',' - ');$this->options->title();} elseif($this->is('archive')){$this->archiveTitle('年','存档: ','月 - ');$this->options->title();} else{$this->archiveTitle('','','');}?> </title> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">或使用(默认):</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->archiveTitle('', '', ' - '); ?><?php $this->options->title(); ?>-<?php $this->options->description(); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">最后给出一个较全面的判断:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php if($this->is('index')){ ?> <?php $this->options->title(); ?>&#160;&#45;&#160;<?php $this->options->description(); ?> <?php if($this->_currentPage>1) echo '第 '.$this->_currentPage.' 页 '; ?> <?php } else if($this->is('category')) { ?> Category: <?php $this->archiveTitle(' &lt; ','',''); ?>&#160;&#45;&#160;<?php $this->options->title(); ?> <?php } else if($this->is('tag')) { ?> Tag: <?php $this->archiveTitle(' &lt; ','',''); ?>&#160;&#45;&#160;<?php $this->options->title(); ?> <?php } else if($this->is('archive')) { ?> Keyword: <?php $this->archiveTitle(' &lt; ','',''); ?>&#160;&#45;&#160;<?php $this->options->title(); ?> <?php } else if($this->is('attachment')) {?> Attachment: <?php $this->archiveTitle(' &lt; ','',''); ?>&#160;&#45;&#160;<?php $this->options->title(); ?> <?php } else { ?> <?php $this->archiveTitle('', '', ''); ?>&#160;&#45;&#160;<?php $this->options->title(); ?> <?php } ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;"><!--more--></h3> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">2、相关文章的调用:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->related(5)->to($relatedPosts); ?> <?php if ($relatedPosts->have()): ?> <?php while ($relatedPosts->next()): ?> <li> <a href="<?php $relatedPosts->permalink(); ?>" title="<?php $relatedPosts->title(); ?>"><?php $relatedPosts->title(); ?></a> <small class="info"><strong><?php $relatedPosts->author(); ?></strong> post in<?php $this->date('Y-m-d H:i:s'); ?></small> </li> <?php endwhile; ?> <?php else : ?> <li>No Related Post</li> <?php endif; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">3、输出Tags</h3> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">输出所有(最好把它用在单独页面中):</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Metas_Tag_Cloud') ->parse('<span class="tagcloud"><a href="{permalink}">{name}</span></a>'); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">或者使用<strong style="margin: 0px; padding: 0px; outline: 0px; border: 0px;">(推荐)</strong>(使用于边栏):</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Metas_Tag_Cloud', array('sort' => 'count', 'ignoreZeroCount' => true, 'desc' => true, 'limit' => 20))->to($tags); ?> <?php while($tags->next()): ?> <li> <a rel="tag" href="<?php $tags->permalink(); ?>" ><?php $tags->name(); ?></a> </li> <?php endwhile; ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">注:20控制输出数量</p> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">4、分页只显示新文章、旧文章</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->pageLink('? 新文章','prev'); ?> <?php $this->pageLink('旧文章 ?','next'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">5、测边栏每月归档后面显示文章数</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Contents_Post_Date', 'type=month&format=Y年m月') ->parse('<li><a href="{permalink}">{date}</a> <span id="ignore">({count})</span></li>'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">6、复制文章时带版权(注意这是JS)</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><script type="text/javascript"> function copy_code(text) { if (window.clipboardData) { window.clipboardData.setData("Text", text) alert("已经成功复制到剪贴板!"); } else { var x=prompt('你的浏览器可能不能正常复制\n请你手动进行:',text); } //return false; } </script> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">7,标签云</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Metas_Tag_Cloud', 'ignoreZeroCount=1&limit=20′)->to($tags); ?> <?php while($tags->next()): ?> <a href=”<?php $tags->permalink(); ?>”><?php $tags->name(); ?></a> <?php endwhile; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">8,最新文章</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Contents_Post_Recent')->to($post); ?> <?php while($post->next()): ?> <a href=”<?php $post->permalink(); ?>” title=”<?php $post->title(); ?>”> <?php $post->title(25, '…'); ?></a> <?php endwhile; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">9,相关内容</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->related(5)->to($relatedPosts); ?> <?php while ($relatedPosts->next()): ?> <a href=”<?php $relatedPosts->permalink(); ?>” title=” <?php $relatedPosts->title(); ?>”><?php $relatedPosts->title(); ?></a> <small><strong><?php $relatedPosts->author(); ?></strong> post in <?php $this->date('Y-m-d H:i:s'); ?></small> <?php endwhile; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">10,日期归档显示统计数量</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Contents_Post_Date', 'type=month&format=F Y')->parse('<li><a href=”{permalink}”>{date}</a> ({count})</li>'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">11,友情链接 要装插件</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php PageToLinks::output('links', 'h3', 'ul'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">12,头部关键信息</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->keywords('_'); ?> //关键词 <?php $this->options->title(); ?> //站点名称 <?php $this->options->description(); ?> //站点描述 <?php $this->archiveTitle(); ?> //标题 <?php $this->options->themeUrl('ie.css'); ?> //模板路径 <?php $this->options->siteUrl(); ?> //主页网址 <?php $this->options->feedUrl(); ?> <?php $this->options->commentsFeedUrl(); ?> <?php $this->pageNav(); ?> //分页 <?php $this->options->generator(); ?> //版本号 </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">13,文章页面相关参数调用</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->title(); ?> //标题 <?php $this->category(','); ?> //分类 <?php $this->tags(', ', true, ''); ?> //标签 <?php $this->date('F jS, Y') ?> //时间 <?php $this->content(); ?> //内容 <?php $this->thePrev('&laquo; %s', ''); ?> //上一篇 <?php $this->theNext('%s &raquo;', ''); ?> //下一篇 </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">14,全部文章列表代码,可以应用在任何地方:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->parse('<li>{year}-{month}-{day} : <a href="{permalink}">{title}</a></li>'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">15,全部标签集列表</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Metas_Tag_Cloud') ->to($taglist); ?><?php while($taglist->next()): ?> <li><a href="<?php $taglist->permalink(); ?>" title="<?php $taglist->name(); ?>"><?php $taglist->name(); ?></a></li> <?php endwhile; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">16,全部日志数量:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $stat = Typecho_Widget::widget('Widget_Stat') ;echo ".$stat->PublishedPostsNum."; ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">17,使用下面这个方法,可以自定义首页的文章显示条数,以及自定义分类文章显示:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;">function themeInit($archive) { if ($archive->is('index')) { $archive->parameter->pageSize = 10; // 自定义条数 } } </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">或者:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;">function themeInit($archive) { if ($archive->is('category', 'default')) { $archive->parameter->pageSize = 10; // 自定义条数 } } </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">18,调用某分类文章,pageSize是数量,mid是分类号:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Archive@index', 'pageSize=6&type=category', 'mid=1') ->parse('<li><a href="{permalink}">{title}</a></li>'); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">19,侧栏评论忽略博主评论</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Comments_Recent','ignoreAuthor=true')->to($comments); ?> </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">20,typecho自动显示摘要,180为自动摘要的字数</h3> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">(有人说是一半,可能他们的意思是字节吧)</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->excerpt(180); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">在这里提醒大家一下:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->excerpt(180,'ABC'); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">则ABC是文章后的省略符号,默认是"..."你可以用</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->excerpt(180,''); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">将其定义为空字符串,然后在“阅读全文”后面加上"..."我个人觉得这样好看一点。</p> <blockquote style="margin: 8px 0px; padding: 8px 10px; outline: 0px; border: 1px solid #dddddd; word-wrap: break-word; word-break: break-all; background-color: #f8f8f8; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;"> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; display: inline;">Typecho多数调用语句都有类似的参数,随意组合一下,说不定会有<strong style="margin: 0px; padding: 0px; outline: 0px; border: 0px;">惊喜</strong>呢。</p> </blockquote> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">21,评论输出:</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $comments->author(true); ?>//输出评论人昵称,参数true为带链接的,false为不带链接的; //ps.其实还有一个参数,类型也是布尔,作用是是否带noFollow <?php $comments->excerpt(18, '...'); ?>//输出评论摘要,第一个参数是要截取的长度,第二个是截取后的字符串; <?php $comments->permalink(); ?>//获取当前评论链接,木有参数; <?php $comments->title(); ?>//获取当前评论标题,同样木有参数; <?php $comments->dateWord(); ?>//输出词义化日期,就是输出“3小时前”、“三天前”之内的; <?php $comments->gravatar(); ?>//调用gravatar输出用户头像,有两个参数,第一个是头像尺寸,默认是32,第二个是默认输出的头像。 </code></pre> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">22,分离文章的评论和引用通告:</h3> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">打开模板的 comments.php 文件,找到通篇的核心语句:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->comments()->to($comments); ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">这条语句控制着评论的类型,他的参数如下:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this→comments()→to($comments); ?> 显示全部(默认) <?php $this→comments('comment')→to($comments); ?> 只显示 comment <?php $this→comments('trackback')→to($trackbacks); ?> 只显示 trackback <?php $this→comments('pingback')→to($pingbacks); ?> 只显示 pingback </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">为了分开,我们开始对 comments.php 做如下修改,首先只显示评论:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->comments('comment')->to($comments); ?> <?php if ($comments->have()) : ?> <ol> <?php while ($comments->next()) : ?> <li id="<?php $comments->theId() ?>"> <div class="comment_data"> <?php $comments->gravatar(32, '', '', 'avatar'); ?> <span><?php $comments->author() ?></span> Says:<br /> <?php $comments->date('F jS, Y'); ?> at <?php $comments->date('h:i a'); ?> </div> <div class="comment_text"><?php $comments->content() ?></div> </li> <?php endwhile; ?> </ol> <?php endif; ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">然后输出 pingback,pingback 并不需要那么多的展示内容,假设只展示标题和日期:</p> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->comments('pingback')->to($pingbacks); ?><!-- 关键 --> <?php if ($pingbacks->have()) : ?> <h3>Pingbacks</h3> <ol> <?php while ($pingbacks->next()) : ?> <li id="<?php $pingbacks->theId() ?>"> <?php $pingbacks->author() ?> <?php $pingbacks->date('F jS, Y'); ?> </li> <?php endwhile; ?> </ol> <?php endif; ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">如果你要显示 trackback,也可以按如上的修改。</p> <h3 style="margin: 20px 0px; padding: 0px 0px 0px 7px; outline: 0px; border-width: 0px 0px 0px 4px; border-left-style: solid; border-left-color: #547d49; font-weight: normal; font-size: 16px; height: 24px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; line-height: 28px;">23,Typecho文章标题字数限制</h3> <pre style="margin-top: 8px; margin-bottom: 8px; padding: 8px 10px; outline: 0px; border-left-width: 3px; border-color: #cccc99 #cccc99 #cccc99 #547d49; word-wrap: break-word; word-break: break-all; background-color: #f7f7b5; border-top-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 3px; color: #505555; font-size: 14px; line-height: 28px;"><code style="margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; border: 0px;"><?php $this->widget('Widget_Contents_Post_Recent')->to($post); ?> <?php while($post->next()): ?> <li><a href="<?php $post->permalink(); ?>"><?php $post->title(25, '...'); ?></a></li> <?php endwhile; ?> </code></pre> <p style="margin: 0px 0px 18px; padding: 0px; outline: 0px; border: 0px; color: #505555; font-family: miranafont, 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; font-size: 14px; line-height: 28px;">其具体作用:边栏文章单行显示;因有时边栏标题过长而换行时会使页面排版或动态效果有不完美的地方,此法便可解决。</p> 相关文章 自建php仿新浪短网址服务 Golang 汇编入门知识总结 未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序 如何学习一门新的语言 Centos7 下安装Golang JavaScript Array 数组常用函数 网页复制内容时自动添加版权链接信息 百度搜索自动提交网站内容 handsome 主题添加相关文章 Typecho在PHP7以上版本中出现"Database Server Error"错误的解决办法 Last modification:April 8th, 2015 at 03:18 pm © 允许规范转载 Support 如果觉得我的文章对你有用,请随意赞赏 ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat