正如我所看到的每个模板文件都存在一个连接特定模块块的布局。我挣扎着理解Magento的每个块,让我解释我做了什么,在Magento中使用布局
考虑一个模板app\design\frontend\base\default\template\catalog\category\view.phtml
我们,$_category = $this->getCurrentCategory();
此功能属于阻止app\code\core\Mage\Catalog\Block\Category\view.php
什么Magento的模板它的搜索布局,而不是块文件,
即,内部布局文件,app\design\frontend\base\default\layout\catalog.xml
我们有,<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
在该布局中的定义,type
属性定义块文件, 即,通过布局文件模板获取从块getCurrentCategory()
函数的值。
另外我们有<reference name="content">, <reference name="left">
它决定在哪里追加模板。
我的问题是,
为什么不能
Templates
从Block
直接获得价值,而不指Layout
?为什么Magento不允许我们这样做?
在考虑这些3块,布局和模板时,布局有什么用处?
你的所有定义敲我明白究竟会在Magento设计区内。谢谢。 – Vinith