我已经创建了一个自定义模块,它向magento类别添加一个属性,并在我的类别页面上显示此属性。Magento:是否有可能将块添加到类别视图上的其他块而无需编辑catalog.xml
首先,我编辑了category/view.phtml模板文件以直接检索我的属性。工作正常,但不是一个真正的解决方案,因为我不得不编辑默认的模板文件。
因此,我创建了自己的布局.phtml文件,它在类别页面上呈现自定义块。只要我使用'content'作为参考,这很好。
<catalog_category_default>
<reference name=\"content\">
<block type=\"categoryreadmore/readmore\" name=\"slim_readmore\">
事情是,这没有做我所需要的。我需要将我的块直接放在类别描述下!在catelog.xml中,如果在类别视图中找到了它。
<reference name=\"content\">
<block type=\"catalog/category_view\" name=\"category.products\" template=\"catalog/category/view.phtml\">
<block type=\"catalog/product_list\" name=\"product_list\" template=\"catalog/product/list.phtml\">
所以我需要的是我的块放在上面的\里面\”所属类别\”” category.products \”块。
这甚至可以不编辑catalog.xml吗?我想要一个单一包模块,而不必在每次安装模块时编辑默认模板。
在此先感谢!
任何想法?
我的假设是,这是不可能的,这将是一个遗憾
我当前的代码
config.xml文件:
<frontend>
<layout>
<updates>
<readmore>
<file>readmore.xml</file>
</readmore>
</updates>
</layout>
readmore.xml
<catalog_category_default>
<reference name="content">
<block type="categoryreadmore/readmore" name="slim_readmore" before="product_list" >
<action method="setTemplate"><template>readmore/readmore.phtml</template></action>
</block>
</reference>
</catalog_category_default>
你有没有找到你的解决方案?我也在寻找它.. –
我确实得到了很多,但从来没有发现如何使用它,而无需在模板文件中进行任何编辑。只是没有得到它使用下面的答案工作。我确实使用自定义创建的模块“读更多”,为每个可以管理文本和标签的分类添加额外的字段。让我知道你是否对代码感兴趣。 – user1281146