Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 579 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where is the content of <?php echo $this->getChildHtml(’right’) ?>

#1
I’m trying to re-organise my right sidebar. In the template (2columns-right), it calls :

`<?php echo $this->getChildHtml('right') ?>`

Where can I find the content of this variable?
Reply

#2
You will find <reference name="right"> in your layout.xml file from where everything comes.It would have list blocks under which call .phtml files and data comes from there.I hope you understand what I am trying to convey.
Reply

#3

<reference name="right">
<block type="yourmodule/yourblock" name="yourblock" as="yourblock" />
</reference>

You can add your custom blocks over there like this.
Reply

#4
A call to method `getChildHtml()` loads the HTML for the child block with the name which is passed to the method, so in this case we are looking for a child block named *right*.

To determine where to find this child block we need to know which block is calling this method. I know that that particular call to the `getChildHtml()` method appears in the main page column template as *right* is one of the columns. So have a look in the `page.xml` layout file and search for 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>` tag in a layout file allows you to alter the targeted block, and the `<action>` tag allows you to run a block method inside the block you are working with. So this section of layout sets the template inside the *root* block. From this we know that it is the *root* block calling the `getChildHtml()` method.

Next lets look at where the *root* block is defined in the layout, it's in the same `page.xml` layout file, and should be right near the top:

<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 quite a lot defined in this block, but you can see that it is given the name *root* and defines quite a few child blocks. One of these child blocks is named *right* and it is this block whose HTML is being output by the `getChildHtml()` method. It is important to note the block type - `core/text_list`. This is a special block type which means that when rendering out the HTML for this block using the `getChildHtml()` method, child blocks will also be rendered. If the block type was `page/html` like with the root block, every child block added to the *right* block would need it's own `getChildHtml()` method call, using this block type, you only need a call to `getChildHtml('right')` and all child blocks will also be rendered.

As you can see the *right* block is defined here but it is empty. This is because in exactly the same way as your have the tag referencing the root block (`<reference name="root">`) other layout files add child blocks to the *right* block by referencing the *right* block.

<reference name="right">
...
</reference>

So to finally answer your question (and hopefully inform a little along the way), you need to be looking in layout files other than `page.xml` for references to the *right* block, here you will find all of the child content output by the `getChildHtml()` method call.

You can alter what is added to the *right* block in your own module layout file, or `local.xml` layout file if you are not creating a module. I briefly cover the `local.xml` layout file in my answer [here][1] with example syntax to add new blocks and remove blocks added in other layout files.


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through