如果您需要自定义布局句柄 local.xml,’相当简单。在此示例中,observer方法将为有或没有子类别的类别创建新的句柄,但是您可以修改该方法以使其成为所需的任何句柄。 (我在那里创建后意识到’s已经是没有子类别的锚定类别的处理程序,catalog_category_layered_nochildren
)
首先,将其添加到您的custommodule中的config.xml中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<config> <frontend> <events> <controller_action_layout_load_before> <observers> <yourcustomtheme_observer> <class>您的自定义主题/观察者</class> <method>addHandles</method> </ yourcustomtheme_observer> </observers> </ controller_action_layout_load_before> </events> </frontend> </config> |
然后将此方法添加到您的观察者:
1 2 3 4 5 6 7 8 9 10 11 12 |
类 YourPackage_YourCustomTheme_Model_Observer 延伸 CLS_Core_Model_Abstract { 上市 功能 addHandles($观察者) { $类别 = 法师::注册表(“ current_category”); 如果 ($类别 实例 Mage_Catalog_Model_Category) { $更新 = 法师::getSingleton(“核心/布局”)->获取更新(); 生育率 = (<a href="http://www.php.net/count" 目标=“_空白” rel=“ noopener”>计数</a>($类别->getChildren类别()->getData())) ? “父母” : '没有孩子'; $更新->addHandle('catalog_category_' . 生育率); } 返回 $ this; } } |
该网站使用Akismet减少垃圾邮件。 了解如何处理您的评论数据.