Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Content block displayed only on “home” page, and not in category, sales, .. layouts
 
lucasl
Jr. Member
 
Total Posts:  5
Joined:  2008-07-25
 

Hi there, thanks for such a great framework!

I have created a custom way of displaying categories in my site’s home page, and as a result I created a template file inside category/navigation/ which iterates through all categories and displays them according to my needs.

I then went ahead and modified page.xml in my “modern theme” layouts and added the following line inside the ‘content’ structural block:

<block type="core/text_list" name="content" as="content">
<block type="catalog/navigation" name="contentmenu" as="contentmenu" template="catalog/navigation/contentmenu.phtml" />
</block>

Finally I went to sample\home.phtml and added a $this->getChildHtml(’contentmenu’) to display the categories in this sample homepage.

So far so good? My problem is that given the categories template was declared as a child for “content” which is a structural block, it appears in every single page that makes use of the content block.

I have found a way of “unsetting” a certain content block from within other xml files - meaning that I would have to go to category.xml and every other xml which displays the categories and unset the ‘contentmenu’ block.

Is there a better way? Is there an xml file specifically for the home page where I can reference the content structural block and add a child right there?

This looks like an ugly workaround that I’m not really comfortable with smile I simply want the categories to be displayed in the main page. If I add all the php code in home.phtml then I’m not in the corresponding namespace to access the categories.

Thanks for your help!

/Lucas

 
Magento Community Magento Community
Magento Community
Magento Community
 
lucasl
Jr. Member
 
Total Posts:  5
Joined:  2008-07-25
 

Please anyone?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
lucasl
Jr. Member
 
Total Posts:  5
Joined:  2008-07-25
 

Hello? Please anyone can advice on this?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
gamelodge
Sr. Member
 
Avatar
Total Posts:  89
Joined:  2007-08-31
Brisbane, Qld, Australia
 

If you add something like this to your CMS home page in custom design tag then it will add the update to only the home page [ do this through admin interface cms tab]

<reference name="content">
<block type="catalog/navigation" name="contentmenu" as="contentmenu" template="catalog/navigation/contentmenu.phtml" />
</reference>

in my actual page contentmenu.phtml i would add something like this:  [ this is my version of doing a similar thing]

$cats $this->getStoreCategories();
    
$x 0;
    
?>

<div id="midmenu-container">
  
<?php 
    
foreach ($cats as $_category): 
        if(
$x == || $x ==){echo '<ul id="simple-menu">';}
        
echo $this->drawItem($_category);
        if(
$x ==){echo '</ul>';}
            $x
++;
    endforeach;
?>
</div>
 
Magento Community Magento Community
Magento Community
Magento Community
 
lucasl
Jr. Member
 
Total Posts:  5
Joined:  2008-07-25
 

You, dear friend, are absolutely correct!

Thank you so much for your help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 

Hi guys, could you please explain how to do that?. I’m very newby to Magento so I can’t understand what are you doing…

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 
lucasl - 08 August 2008 10:26 AM

You, dear friend, are absolutely correct!

Thank you so much for your help!

Since you are adding it to the Content of your home page CMS, you could also use:

{{block type="catalog/navigation" name="contentmenu" template="catalog/navigation/contentmenu.phtml" }}

This goes in the General Information tab in the admin > CMS > Manage Pages section.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lucasl
Jr. Member
 
Total Posts:  5
Joined:  2008-07-25
 

Great!! Thanks.

I used the first solution and played around with the after="” or before="” attributes which end up placing the block after or before another block.

It makes a lot more sense this way, thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top