如何在 Magento Fishpig 的自定义模板上显示类别 post?

How to display category post on custom template in Magento Fishpig?

我的项目中有两个 post 类别,这两个类别使用不同的视图。我正在使用 fishpig 插件添加和分类 post,但是两个类别 post 都使用相同的 view.phtml 模板来显示 post.

<wordpress_post_view>
    <reference name="content">
        <block type="wordpress/post_view" name="wp.post.view" template="wordpress/post/view.phtml">
            <block type="core/text_list" name="post.content.before" as="before_post_content" />
            <block type="core/text_list" name="post.content.after" as="after_post_content">
                <block type="wordpress/post_meta" name="wp.post.view.meta" as="meta" after="-" template="wordpress/post/meta.phtml">
                    <action method="setDisplayPreviousNextLinks"><display>1</display></action>
                </block>
            </block>
            <block type="wordpress/post_view_comment_wrapper" name="wp.post.view.comments" as="comments" template="wordpress/post/view/comment/wrapper.phtml">
                <block type="wordpress/post_view_comments" name="wp.post.view.comments.list" as="comment_list" template="wordpress/post/view/comments.phtml" />
                <block type="wordpress/post_view_comment_pager" name="wp.post.view.comments.pager" as="pager"/>
                <block type="wordpress/post_view_comment_form" name="wp.post.view.comments.form" as="form" template="wordpress/post/view/comment/form.phtml">
                    <block type="core/text_list" name="wp.post.view.comments.form.before_end" as="before_form_end" />
                </block>
            </block>
        </block>
    </reference>
    </wordpress_post_view>

有什么方法可以拆分post视图吗?

最好的方法是使用 2 种不同的 post 类型,而不是按类别拆分 post。这将允许您很容易地为每个 post 类型创建一个单独的模板。

如果要使用类别,则需要自定义 view.phtml 并添加检查以查看当前 post 属于哪个类别,然后显示相应的内容。