指定类别特定布局更新,无需使用 Magento 的管理仪表板
有没有一种方法可以指定特定类别的布局更新(例如使用类别ID),而无需使用管理仪表板,并设置[自定义设计>自定义布局更新]。
我确信我可以创建一个模块来查找类别 ID 并根据该 ID 切换布局,但我很好奇自 Zend 以来是否有布局文件的命名或其他类型的约定允许这种类型的粒度控制框架有时允许这样的命名约定。
另外,在catalog.xml 文件本身中,可能还存在允许这种粒度的附加“布局”,比
更具体。
Is there a way to specify a layout update for a specific category (e.g. using category ID) without having to use the administration dashboard, and setting a [Custom Design > Custom Layout Update].
I am sure I can create a module that looks for a category ID and switches the layout based upon that, but I was curious if there was a naming or some other type of convention for layout files that allows for this type of granular control since Zend Framwork sometimes allows such naming conventions.
Also maybe within the catalog.xml file itself there are additional "layouts" that allow such granularity, something more specific than <catalog_category_layered />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在标准 Magento 安装(1.4.2,但它应该适用于其余版本)中,Magento 发出以下布局句柄(句柄告诉 Magento 从包布局加载哪个布局更新 XML 片段)
以下布局句柄
是根据类别的 ID。这意味着您应该能够将如下内容添加到您的
local.xml
中,或者添加到通过自定义模块添加的自定义布局 XML 文件中In a standard Magento install (1.4.2, but it should apply to the rest), Magento issues the following Layout handles (handles tell Magento which Layout Update XML Fragments to load from the Package Layout)
The following layout handle
is generated based on the ID for a category. This means you should be able to add something like the following to your
local.xml
, or to a custom layout XML file added via a custom module当访问目录类别时,Magento 会加载
CATEGORY_${ID}
的句柄,您可以使用它来执行您所要求的操作。When visiting a catalog category, Magento loads a handle for
CATEGORY_${ID}
, which you can use to do exactly what you are asking.