0
问题:需要截断帖子。如何截断使用PHP的帖子?
当前情况:整篇文章正在显示。 [阅读更多...]错误的位置。
目标:截断到350个字符的帖子显示。放置“[阅读更多...]”文字结尾。
请参阅当前的代码:
<?php if ($posts = $this->getRecent()):
// get The ReadMore value from configuration
$configReadmore = Mage::getStoreConfig('blog/blog/readmore',Mage::app()->getStore());
?>
<div class="widget-latest">
<center><font size=6em><font color=004689><?php echo Mage::helper('blog')->__('Top Articles'); ?></font size></font color></center>
<ul style="list-style: none; padding-left: 0px;">
<?php foreach ($posts as $post): ?>
<li style="border: 1px solid #9a9a9a; margin-bottom: 10px;">
<div class="postTitle">
<h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>
</div>
<?php echo $post->getShortContent(); ?>
<br/><br/><a href="' . $post->getAddress() . '">[Read More...]</a>
</li>
<?php endforeach; ?>
</ul>
</div>
底部网站:http://www.statis-online.com
所有帮助是非常感谢!
感谢伙计!最终代码的工作如下: <?php echo Mage :: helper('core/string') - > truncate($ post-> getShortContent(),350); ?> – Lykingond 2014-12-11 14:30:27
你会碰巧知道如何制作代码**************“[Read More...]”***************代码显示红色字体没有打破链接?此代码打破了链接:/ – Lykingond 2014-12-11 16:23:44