正如我所看到的每個模板文件都存在一個連接特定模塊塊的佈局。我掙扎着理解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