没有效果,直接显示全文

模板开发以及发布测试

版主: seita

回复
testall
帖子: 2
注册时间: 2010年 5月 16日 15:11

没有效果,直接显示全文

帖子 testall »

代码: 全选

 $this->need('header.php');
 ?>
    <div class="grid_10" id="content">
   <?php while($this->next()): ?>
        <div class="post">
        <h2 class="entry_title"><a href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
         <p class="entry_data">
            <span><?php _e('作者:'); ?><?php $this->author(); ?></span>
            <span><?php _e('发布时间:'); ?><?php $this->date('F j, Y'); ?></span>
            <span><?php _e('文章分类:'); ?><?php $this->category(','); ?></span>
                </p>
                [i][u][b]<?php $this->content('阅读全文'); ?>[/b][/u][/i]
         <span class="span_right"><a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('暂无评论', '1 条评论', '%d 条评论'); ?></a></span>
         <div class="clearfix"></div>
        </div>
   <?php endwhile; ?>
        <ol class="pages clearfix">
            <?php $this->pageNav(); ?>
        </ol>
    </div><!-- end #content-->
   <?php $this->need('sidebar.php'); ?>
   <?php $this->need('footer.php'); ?>

<?php $this->content('阅读全文'); ?>
这句代码写上没有效果,直接显示全文,那里写错了???
请高人指点.
头像
m4go
帖子: 857
注册时间: 2010年 3月 29日 02:33
来自: https://www.vpshu.com
联系:

Re: 没有效果,直接显示全文

帖子 m4go »

如果这样写,需要<!--more-->来做截断。
如果想自动截断:<?php $this->excerpt(160, '……'); ?>替换<?php $this->content('阅读全文'); ?>一下试试?
其中160是字符数。
testall
帖子: 2
注册时间: 2010年 5月 16日 15:11

Re: 没有效果,直接显示全文

帖子 testall »

多谢M4go,可是如下写法:

代码: 全选

 <p><?php $this->excerpt(160, '......'); ?></p>
                           <a href="<?php $this->permalink() ?>">阅读全文</a>

有没有更简单的方法呢?
回复