2010-11-18 122 views
1
<block type="catalog/product_compare_sidebar" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/> 
<block type="catalog/product_list"...> 

我研究了http://magebase.com/magento-tutorials/demystifying-magentos-layout-xml-part-1/,它提到了一个type属性,它定义了块的类名。在上面的代码中,catalog/product_compare_sidebar和catalog/product_list应该是一个块类,所以,声明这些块的php文件的位置在哪里(任何来自“catalog/product_compare_sidebar”和“catalog/product_list”的提示“)?Magento - 布局

有许多块类型,我怎么知道哪些块类型可用以及如何选择哪种块类型适合现有块?

感谢您

回答

2

这里是联想:

catalog/product_compare_sidebar => /app/code/core/Mage/Catalog/Block/Product/Compare/Sidebar.php 
catalog/product_list => app/code/core/Mage/Catalog/Block/Product/List.php 

如果你使用Eclipse PDT,只需按下按Ctrl + + 牛逼和类型: *目录* Product_Compare_Sidebar到找到第一堂课。

更新:搜索“类”将为您提供所有可用的块类型。 如果你使用Eclipse PDT,只要按下Ctrl键++Ť类型: 。 链接末尾的段落描述了最重要的一段。 Personnaly,我经常创建自己的类型并从Mage_Core_Block_Template继承,或者直接使用它。

UPDATE_2:在Mage_Core_Block_Abstract,你可以看到这个方法

我认为,必须调用每个XML属性的地方。要知道在哪里,只需在此处放置一个断点,或者在这里死掉,然后查看堆栈跟踪。

+0

感谢您的信息,但如何“有很多块类型,我怎么知道哪种块类型可用以及如何选择哪种块类型适合现有块?” – 2010-11-18 11:01:03

+0

@Charles Yeung:看到更新超过 – greg0ire 2010-11-18 11:05:51

+0

谢谢你,还有一件事“{{block type =”catalog/product_list“category_id =”5“template =”catalog/product/list.phtml“}}”怎么会这样有属性category_id? – 2010-11-18 11:26:52