0

I'm writing a new layout file for a custom module. As part of this I need to include the toplinks eg. log in, cart + (quantity), my account, wishlist and also recently viewed and nothing else. My layout file looks like so,

  <?xml version="1.0"?>
  <layout version="0.1.0">
<dynamicblocks_index_index>
    <block type="core/template" name="root" output="toHtml" template="dynamicblocks/index.phtml" >
        <block type="page/template_links" name="top.links" as="topLinks"/>
        <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
    </block>
</dynamicblocks_index_index>

I got the link for loading the toplinks from page.xml

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

I am sure this is what loads the correct information on the main pages as when I comment it out all of the top links disappear. But in my custom layout it is only able to load one link (login). I also can't see how my layout file is wrong or reference incorrectly as it loads the recently viewed products as I expected.

The issue I'm having is that the top links is only returning the log in link. Any ideas on this?

7
  • top links is only returning the log in link? I'm not getting it Mar 20, 2014 at 11:10
  • in the page.xml layout it returns -> log in, my account, checkout, cart and my wishlist. Mar 20, 2014 at 11:11
  • is there any reference you are looking at? for new layout file. Mar 20, 2014 at 11:13
  • by reference what do you mean, reference tag? if so no Mar 20, 2014 at 11:14
  • is there any blog you are following for doing this? Mar 20, 2014 at 11:15

2 Answers 2

1

In order to get the page to just display the links that i wanted I had to tell the xml to remove certain files. This is my updated xml

  <dynamicblocks_index_index>

    <reference name="root">
        <action method="setTemplate"><template>dynamicblocks/index.phtml</template></action>
    </reference>   

    <reference name="header">
        <remove name="store_language" />
        <remove name="catalog.topnav" />
        <remove name="top.search" />
    </reference>

    <!-- <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> -->

</dynamicblocks_index_index>
0

This answer is based on the discussion.

Before continuing you must check this answer in order to properly add the new layout template.

Your layout file should look like:

<?xml version="1.0"?>
<layout version="0.1.0">
    <dynamicblocks_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>module/file/path/template.phtml</template>
            </action>
        </reference>
    </dynamicblocks_index_index>
</layout>

And in your template file you told that the code written is: $this->getChildHtml();
Actually the problem there is that you had not specified the name of the block, that's why you are getting everything whether you just need the top links. So the code in your template file might look like:

$this->getChildHtml('top.links');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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