Reputation: 4464
I'm using Magento 1.9.1.0 with the RWD theme and I'd like to show some more menu items (brands, multiple types of links) from a cms/block. I've changed the template/page/html/topmenu/renderer.phtml
file and added this after the closing </ul>
:
$identifier = str_replace(array(Mage::getBaseUrl(),'/'),array('','-'),$child->getUrl());
$html .= '<div class="brands">';
$html .= $this->getLayout()->createBlock('cms/block')->setBlockId('mainmenu_brands_'.$identifier)->toHtml();
$html .= '</div>';
So this piece of code is inside a foreach()
that loops through the menu items and makes it possible to add some extra links after each menu item.
Normally this should be in a XML, but the identifier of the cms/block is dynamically so I couldn't find a better/nicer solution.
Everything is working perfectly, but.. when I enable caching (the BLOCK_HTML
cache) nothing appears! I've done some troubleshooting and tested some thing out. The dynamic identifier is the problem. When I use a static identifier it's working perfectly, but that way I've the same links everywhere.
How to get this working with caching?
Upvotes: 1
Views: 821
Reputation: 4464
The problem was that Mage::getBaseUrl()
was returning the URL with ?___SID=U
when caching is enabled. So the cms/block identifier had the ?___SID=U
addition. I've disabled the "Use SID on Frontend" option, see: https://magento.stackexchange.com/a/59378/8013 and now it's gone and working perfectly! We're just using one store so this option can be disabled.
Upvotes: 1