2014-03-26 113 views
0

我需要在Magento中了解这一点。在page.xml,以下块:Magento布局XML

<block type="page/template_links" name="top.links" as="topLinks"/> 

我需要app/design/package/theme/template/page/template/links.phtml

然后下一个数据块::

<block type="page/html_welcome" name="welcome" as="welcome"/> 

为什么我需要查找app/code/core/Mage/Page/Block/Html/Welcome.php

回答

2

在你需要寻找该块类中这两种情况下: 为block type="page/template_links"类是Mage_Page_Block_Template_Links,并且可以在文件中找到app/code/core/Mage/Page/Block/Template/Links.php 如果你看一下里面的类,你会看到:

protected function _construct() 
{ 
    $this->setTemplate('page/template/links.phtml'); 
} 

这指向文件app/design/package/theme/template/page/template/links.phtml 第二个块的类仅设置欢迎消息,并且没有模板。

+0

谢谢艾米,我明白了这件事。 – user3401141

+0

您应该在toHtml,_toHtml,getChildHtml,_getChildHtml等函数中查看抽象类Mage_Core_Block_Abstract,然后查看扩展前一个类的Mage_Core_Block_Template类 – Emi

0

在magento中,我们在xml中设置模板或在Action中设置模板。在你的xml中,你设置了一个块文件。所以通过调用模板内的块函数可以访问该函数。在welcome.php中,您可以设置该值并获取模板中的值。