Where is the content <? Php echo $ this-> getChildHtml (right)?>
I am trying to reinstall the right sidebar. In the template (2 columns on the right), it calls:
<?php echo $this->getChildHtml('right') ?>
Where can I find the contents of this variable?
Calling the getChildHtml() method loads the HTML for the child block with the name that is passed to the method, so in this case we are looking for the child block with the name right.
To determine where to find this child block, we need to know which block calls this method. I know that this particular call to the getChildHtml() method appears in the column template of the main page, since the right is one of the columns. So look in the page.xml layout page.xml and find the template file inside which you found the method call, you will find something like this:
<reference name="root"> <action method="setTemplate"><template>page/2columns-right.phtml</template></action> <!-- Mark root page block that template is applied --> <action method="setIsHandle"><applied>1</applied></action> </reference> Using the <reference> in the layout file allows you to change the target block, and the <action> allows you to run the block method inside the block you are working with. Thus, this section of the layout sets the template inside the root block. From this we know that this is the root block that calls the getChildHtml() method.
Next, let's see where the root block is defined in the layout, it is in the same page.xml layout and should be at the top right:
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml"> ... <block type="core/text_list" name="right" as="right" translate="label"> <label>Right Column</label> </block> ... </block> There is definitely a lot in this block, but you can see that it is given the root name and defines quite a few child blocks. One of these child blocks is called correct, and it is this HTML block that is output by the getChildHtml() method. It is important to note the type of block - core/text_list . This is a special type of block, which means that when rendering HTML for this block using the getChildHtml() method, child blocks will also be displayed. If the block type was page/html as with the root block, each child block added to the right block would need its own call to the getChildHtml() method, using this block type, you only need to get getChildHtml('right') , and that's it child blocks will also be displayed.
As you can see, the right block is defined here, but it is empty. This is because, just like your tag refers to a root block ( <reference name="root"> ), other layout files add child blocks to the right block, referring to the right block.
<reference name="right"> ... </reference> So, in order to finally answer your question (and hopefully to inform you a bit about this), you need to look in layout files other than page.xml for links to the right block, here you will find all the output of the child content by calling the getChildHtml() method getChildHtml()
You can change what is added to the right block in your own module layout file, or the local.xml layout file if you do not create the module. I will briefly talk about the local.xml layout local.xml in the answer here with an example syntax for adding new blocks and removing blocks added to other layout files.
You will find in your layout.xml file where everything will come from. It will have list blocks under which calls will be received .phtml files and data. I hope you understand what I'm trying to convey.
<reference name="right"> <block type="yourmodule/yourblock" name="yourblock" as="yourblock" /> </reference> You can add your custom blocks there like this.