更新某些类别的左列/如何在布局文件中设置类别 ID [英] Update left column for certain Category/how to set Category Id in layout file

查看:44
本文介绍了更新某些类别的左列/如何在布局文件中设置类别 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个在某些类别的左侧显示幻灯片的图块.但是,通过引用布局文件中的左列,我在所有页面上都显示了幻灯片显示块.我们需要幻灯片放映仅出现在左侧的某些类别(id 225)中.

到目前为止,我的解决方案路线图:
1.将特定类别的网址重写为我的自定义模块/控制器/操作(测试/索引/索引)
2.在测试/索引/索引布局文件test.xml中,我想覆盖目录句柄catalog_category_default(我是通过使用Alan Storm布局视图解决方案

在admin部分中,在编辑类别以应用布局更新时会有一个字段,您可以在其中添加块XML.如果您希望将其包含在代码中,则类别页面会添加一个包含其ID的句柄",例如"CATEGORY_123",您可以通过引用以下内容来添加代码块:

 < CATEGORY_123><参考名称=左">< block type =">(等等.)</reference></CATEGORY_123> 

I would like a block that display slide show on left side for certain category. I got the slide show block display in all pages by referencing left column in layout file, however. We need the slide show appear only in certain category(id 225) on the left side.

My solution road map so far:
1. rewrite the particular category's url to my customized module/controller/action(test/index/index)
2. In test/index/index layout file test.xml i would like to override catalog handle catalog_category_default(i got this by using Alan Storm Layout Views
http://alanstorm.com/category/magento) that will have updated left column with my new slide show block. This is how looks my test.xml file

This is giving me following error: Fatal error: Call to a member function getMetaTitle() on a non-object in /app/code/local/Mage/Catalog/Block/Category/View.php on line 43

From the error i conclude that the handle is being overided, however there is missing category id because the line 43 is:

if ($title = $this->getCurrentCategory()->getMetaTitle()) {

As you see, i have tried to set the category id in the test.xml layout file but without much success.

How to set category id in layout file? Is this doable solution or right way to do? Am i really overiding the handle?

Thanks Margots

解决方案

In the admin section, there's a field when editing a category to apply layout updates, you can add your block XML there. If you'd prefer it be in the code, then category pages add a 'handle' that includes their ID, 'CATEGORY_123' for example and you can add your block by referencing that:

<CATEGORY_123>
  <reference name="left">
    <block type=""> (etc.)
  </reference>
</CATEGORY_123>

这篇关于更新某些类别的左列/如何在布局文件中设置类别 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆