diff options
| author | Eltrac <45323514+BigCoke233@users.noreply.github.com> | 2019-07-17 13:28:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-17 13:28:56 +0800 |
| commit | 76317320c58d6c5a859dbf9e8c8d0d1ca06053dc (patch) | |
| tree | 26309679b37f697424a95df8c2d4e0cdc050cf28 | |
| parent | c0a0f26cb2e9715478ce4eeec2c660e738a2d7da (diff) | |
文章支持自定义摘要
| -rw-r--r-- | functions.php | 5 | ||||
| -rw-r--r-- | index.php | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/functions.php b/functions.php index aff2db6..113a1ab 100644 --- a/functions.php +++ b/functions.php @@ -82,6 +82,9 @@ function themeConfig($form) { * 文章与独立页自定义字段 */ function themeFields(Typecho_Widget_Helper_Layout $layout) { - $banner = new Typecho_Widget_Helper_Form_Element_Text('banner', NULL, NULL,_t('缩略图'), _t('输入一个图片 url,作为缩略图显示在文章列表,没有则不显示')); + $banner = new Typecho_Widget_Helper_Form_Element_Text('banner', NULL, NULL,_t('文章头图'), _t('输入一个图片 url,作为缩略图显示在文章列表,没有则不显示')); $layout->addItem($banner); + + $excerpt = new Typecho_Widget_Helper_Form_Element_Text('excerpt', NULL, NULL,_t('文章摘要'), _t('输入一段文本来自定义摘要,如果为空则自动提取文章前 130 字。')); + $layout->addItem($excerpt); }
\ No newline at end of file @@ -31,7 +31,14 @@ $this->need('includes/header.php'); <a href="<?php $this->permalink(); ?>" class="post-link"> <h1 class="post-title"><?php $this->sticky(); ?><?php $this->title(); ?></h1> </a> - <p class="post-excerpt"><?php $this->excerpt(); ?></p> + <p class="post-excerpt"> + <?php if($this->fields->excerpt && $this->fields->excerpt!='') { + echo $this->fields->excerpt; + }else{ + echo $this->excerpt(130); + } + ?> + </p> <p class="post-meta"><i class="iconfont icon-block"></i> <?php $this->category(','); ?> <i class="iconfont icon-comments"></i> <?php $this->commentsNum('None', 'Only 1', '%d'); ?> <i class="iconfont icon-clock"></i> <?php $this->date(); ?></p> <p class="post-button-box"><a href="<?php $this->permalink(); ?>" class="post-button">Read More</a></p> </div> |
