0

I have a local.xml file that I have all of my "includes" in (if you want to call them that).

I have a nav.phtml file that is included inside of the header.phtml file with getChildHtml('nav'). In nav.phtml, I have a file that I want included with getChildHtml('topSearch').

Is this possible? Is there a better implementation?

  • Gone through XML is magento standard. Don't use shortcut for magento. – Sourav Jul 19 '16 at 0:49
  • Welcome to Magento SE. To better understand your question and what you are currently doing, it would help if you show your layout XML code. I guess you are looking for nested blocks which is totally possible but to give a useful answer with code, I would need to know what you already have. – Fabian Schmengler Jul 19 '16 at 6:39
2

Fixed it by including this :)

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('template/templateName.phtml')->toHtml(); ?>
0

Yes Possible to use getChildHtml('topSearch') in header file.

Your local.xml code:

{{block type="module/blockfile" template="path to template"}}
0

Follow bellow steps

Step : 1 add bellow code in your local.xml file

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
       <reference name="top.search">
            <block type="core/template" name="top.search.nav" as="topSearchNav" template="page/html/nav.phtml" />
        </reference>
    </default>
</layout>

OR

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
       <reference name="top.search">
            <block type="{your-module-name/your-block-name}" name="top.search.nav" as="topSearchNav" template="{your-phtml-file-path}" />
        </reference>
    </default>
</layout>

Note: Add your particular block type & template file in above code for eg. block type : catalog/product_list & template : catalog/product/list.phtml

Step : 2 Now add getChildHtml('topSearchNav') under the file app\design\frontend\{your-package\{your-theme}\template\catalogsearch\form.mini.phtml

Like :

<?php echo $this->getChildHtml('topSearchNav'); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.