Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Layout File Template Reference?

Tags:

magento

I have studied Magento Template basic tutorial. There is a quesion confused me.

Look at this piece of code in checkout.xml. It tells me the system will add two links in the top.links block.

<reference name="top.links">
     <block type="checkout/links" name="checkout_cart_link">
         <action method="addCartLink"></action>
         <action method="addCheckoutLink"></action>
     </block>
</reference>

So I find the top.links block in the page.xml layout file. I want to know which template this block will use. But there is no template attribute in this tag. So anyone can tell me why there is no template attribute here? If that, how can Magento know which template should reference?

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

It told us, there is a top.links block in the header block

like image 598
Ruiwant Avatar asked Dec 07 '25 08:12

Ruiwant


1 Answers

In your layout XML, you can see the class alias for the block is page/template_links. That means the PHP class for the block is Mage_Page_Block_Template_Links. Open the file app/code/core/Mage/Page/Block/Template/Links.php to see how the block behaves. Not all blocks have template files, but in the class definition it looks like this one should:

class Mage_Page_Block_Template_Links extends Mage_Core_Block_Template

Continue reading and you will see that the template file is set in the constructor:

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

So the template file you are looking for is page/template/links.phtml.

like image 168
Anders Thirsgaard Rasmussen Avatar answered Dec 09 '25 01:12

Anders Thirsgaard Rasmussen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!