xml - Wordpress 和 Magento 完全集成的主页帖子的字符/字数限制 (fishpig)

标签 xml wordpress magento integration fishpig

我最近使用fishpig插件安装了一个wordpress,并完全集成到magento中。我正在努力限制主页上帖子的字符/字数。

FishPig 记录了一个用于发布摘录的小部件,包括以下代码:

<block type="wordpress/sidebar_widget_posts" name="wordpress.widget.recent_posts" as="recent_posts" template="wordpress/sidebar/widget/categoryposts.phtml">
    <action method="setTitle"><title>Latest Posts</title></action>
    <action method="setPostCount"><post_count>5</post_count></action>
    <action method="setExcerpt"><display>on</display></action>
    <action method="setExcerptLength"><length>30</length></action>
    <action method="setDate"><date>on</date></action>
    <action method="setCommentNum"><comments>on</comments></action>
</block>

我假设我可以将“setExcerptLength”模仿为“setPostLength”,并将其包含在主页 block 中的 wordpress.xml 中

<block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
    <block type="wordpress/post_list_pager" name="wordpress_post_list_pager">
        <action method="setPostLength"><length>30</length></action>
    </block>
</block>

但是这些似乎没有效果。

我假设所有 wordpress 功能都已完全集成转换为 xml,因此我无法采用通常的根。

对此的任何帮助将不胜感激。

最佳答案

最近使用fishpig插件将wordpress集成到magento中后,我还发现摘录长度没有效果。

无需过多深入研究代码,我的解决方案如下。

不要使用 xml,直接在页面内容中插入以下内容。确保删除您添加的任何 xml。

{{block type="wordpress/sidebar_widget_posts" name="wordpress.widget.recent_posts" post_count="5" title="Latest Blogs" excerpt="on" excerpt_length="250" date="off" comment_num="off" template="wordpress/sidebar/widget/post-hp.phtml"}}

在您的模板目录中

app/design/frontend/default/your_template/template/wordpress/sidebar/widget/

创建一个新文件,post-hp.phtml

将categoryposts.phtml 的内容复制到这个新文件中。

查找并替换

<p class="post-excerpt"><?php echo $post->getPostExcerpt() ?></p>

<p class="post-excerpt"><?php $content = $post->getPostExcerpt(); $content = strip_tags($content); echo substr($content, 0, 250); ?> ...</p>

关于xml - Wordpress 和 Magento 完全集成的主页帖子的字符/字数限制 (fishpig),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14391168/

相关文章:

java - 通过 org.w3c.dom API 公开 JAXB 注解的对象

c++ - 使用 QDomDocument 时报告详细的 XML 错误

magento - 子文件夹中的 Nginx + Magento

javascript - 实现打开/关闭标签功能的最佳方式

wordpress - 如何使用 qTranslate 翻译 "read more"和 wordpress 上的其他按钮?

magento - 使用 Fishpig 在 magento 产品页面上移动相关博客文章

php - Magento 设置资源 : Installer script not running

c# - "Value cannot be null"从一个或多个值为 null 的属性创建 XElement 时

python - Windows 中 Python 编程的最新技术是什么?

php - 将城市文本字段替换为 Woocommerce 中特定国家/地区的城市下拉列表