aimon
Total Posts: 4
Joined: 2008-10-29
Hey Guys,
I am having real troubles adding links to the top menu across the site and would appreciate you heko.
I have included the links in the app/design/frontend/default/default/template/catalog/navigation/top.phtml as described in
http://www.magentocommerce.com/wiki/how-to/add_home_link_to_menu_bar
I can only get the About Us page to show up and this is only in the catalog pages. How can i add menu items across the site (including the homepage and CMS created pages?
My code is as follows
<div class="header-nav-container">
<div class="header-nav">
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
<ul id="nav">
<li><a href="<?php echo $this->getUrl('home')?>"><?php echo $this->__('Home') ?></a></li>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
<li><a href="<?php echo $this->getUrl('contactus')?>"><?php echo $this->__('Contact Us') ?></a></li>
<li><a href="<?php echo $this->getUrl('faq')?>"><?php echo $this->__('FAQ') ?></a></li>
<li><a href="<?php echo $this->getUrl('aboutus')?>"><?php echo $this->__('About Us') ?></a></li>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
</div>
Thanks
Aimon
Posted: October 30 2008
| top
cwsites
Total Posts: 5
Joined: 2008-12-24
Atlanta, GA
It worked for me, I would say to make sure that your
getUrl ( 'contacts' )
is pointed at the right page and that it’s enabled. I know by default the contact us page is “contacts” not “contactus”
Not sure about the others.
Signature
Matt Haff
Atlanta Website Design | Internet Marketing Blog | Follow me on Twitter
Posted: December 24 2008
| top
| # 1
fiber0pti
Total Posts: 79
Joined: 2008-07-10
I’m also having problems with this. I can’t get the about magento page to show up as a menu item without totally destroying the entire output. I’ve added
< li >< a href = "<?php echo getUrl('about-magento-demo-store') ?>" > <?php echo $this -> __ ( 'About' ) ?> </ a ></ li >
to the file: top.phtml
How do I add menu items to link to CMS content?
Posted: May 22 2009
| top
| # 2
Raptor Commerce (toby)
Total Posts: 180
Joined: 2009-01-31
fiber0pti - 22 May 2009 09:34 AM
I’m also having problems with this. I can’t get the about magento page to show up as a menu item without totally destroying the entire output. I’ve added
< li >< a href = "<?php echo getUrl('about-magento-demo-store') ?>" > <?php echo $this -> __ ( 'About' ) ?> </ a ></ li >
to the file: top.phtml
How do I add menu items to link to CMS content?
@fiberOpti - you might want to look at our extension Custom menus which allows you build your own menus, in addition to the standard Magento product categories. We also offer another extension, Supermenu which builds on the functionality of Custom menus and allows you to display multi column drop down menus as used on sites like asos.com
Signature
Raptor Commerce
Creators of the Supermenu extension for Magento
Posted: August 7 2009
| top
| # 3
Sajid iqbal
Total Posts: 14
Joined: 2009-12-08
All links place in above mentioned way worked for me. The problem is how can i get active states for these links?
Posted: April 9 2010
| top
| # 4
mazy
Total Posts: 17
Joined: 2009-04-24
I would also like to know how o get active links working.
Posted: April 17 2010
| top
| # 5
Germán W
Total Posts: 22
Joined: 2010-02-19
-
I would also like to know how o get active links working.
I got active links to work this way:
< li class= "level0 nav-5<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl().'contacts/'):?> active<?php endif;?>" > < a href = "<?php echo $this->getUrl('contacts')?>" > <?php echo $this -> __ ( 'Contact Us' ) ?> </ a > </ li >
What the “php if” does is check if the current URL is the same as this page url and if so it adds the “active” class to the link.
So the .\’contacts\’ part should be what comes after /index.php/ in you pages\’ URL.
Posted: April 23 2010
| top
| # 6
hancoha
Total Posts: 20
Joined: 2010-04-25
Auburn, Alabama
Germán W - 23 April 2010 03:45 PM
-
I would also like to know how o get active links working.
I got active links to work this way:
< li class= "level0 nav-5<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl().'contacts/'):?> active<?php endif;?>" > < a href = "<?php echo $this->getUrl('contacts')?>" > <?php echo $this -> __ ( 'Contact Us' ) ?> </ a > </ li >
What the “php if” does is check if the current URL is the same as this page url and if so it adds the “active” class to the link.
So the .\’contacts\’ part should be what comes after /index.php/ in you pages\’ URL.
This worked great. Is it important to have the / after the page url? For example about-us/. It works just fine for me using about-us but I didn’t know if there was some issue with that. Thanks,
Posted: August 9 2010
| top
| # 7
mancourt
Total Posts: 34
Joined: 2010-08-03
I’m trying to get this to work in Magento 1.4.1 by editing top.phtml using a page “upcoming-sales.html”.
< li class= "level0 nav-5<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl().'upcoming-sales.html/'):?> active<?php endif;?>" > < a href = "<?php echo $this->getUrl('upcoming-sales.html/')?>" > <?php echo $this -> __ ( 'Upcoming Sales' ) ?> </ a > </ li >
It’s not adding a class, is my code wrong or does this hack not work for 1.4.1?
Thanks!
Posted: August 22 2010
| top
| # 8
raska__
Total Posts: 42
Joined: 2009-05-24
Hi,
I think that this is a cache problem.
If you disable Block html cache from admin you will see correct, but is not the solution.....
bye
Posted: September 2 2010
| top
| # 9
chiefair
Total Posts: 1680
Joined: 2009-06-04
For 1.4.1.1
For enabling dynamic top menu and navigation elements, instead of disabling the BLOCK_HTML cache, disable caching of the block element altogether.
Find /app/code/core/local/Mage/Catalog/Block/Navigation.php and save it to your local code store.
Look for the _construct() code block
protected function _construct () { $this -> addData (array( 'cache_lifetime' => false , 'cache_tags' => array( Mage_Catalog_Model_Category :: CACHE_TAG , Mage_Core_Model_Store_Group :: CACHE_TAG ), )); }
And comment out the CACHE_TAG stuff as follows:
protected function _construct () { /* $this->addData(array( 'cache_lifetime' => false, 'cache_tags' => array(Mage_Catalog_Model_Category::CACHE_TAG, Mage_Core_Model_Store_Group::CACHE_TAG), )); */ }
This should force Magento to create a fresh version of Catalog_Block_Navigation each time page reload occurs, allowing you to use Block HTML caching and getting back some speed while enabling the fancy stuff.
EDIT: A more sophisticated and fully modularized way of doing this cache prevention over here
Signature
-----
1) For preserving thy future happiness, thou shalt back up thy HTTP doc directories and Magento database regularly.
2) For preserving thy sanity during module installs and moves, thou shalt disable thy cache and compiler and flush their caches.
Posted: October 31 2010
| top
| # 10
freshwebservices
Total Posts: 150
Joined: 2008-05-27
Leicestershire, UK
chiefair - 31 October 2010 11:15 AM
For 1.4.1.1
For enabling dynamic top menu and navigation elements, instead of disabling the BLOCK_HTML cache, disable caching of the block element altogether.
Find /app/code/core/local/Mage/Catalog/Block/Navigation.php and save it to your local code store.
Look for the _construct() code block
protected function _construct () { $this -> addData (array( 'cache_lifetime' => false , 'cache_tags' => array( Mage_Catalog_Model_Category :: CACHE_TAG , Mage_Core_Model_Store_Group :: CACHE_TAG ), )); }
And comment out the CACHE_TAG stuff as follows:
protected function _construct () { /* $this->addData(array( 'cache_lifetime' => false, 'cache_tags' => array(Mage_Catalog_Model_Category::CACHE_TAG, Mage_Core_Model_Store_Group::CACHE_TAG), )); */ }
This should force Magento to create a fresh version of Catalog_Block_Navigation each time page reload occurs, allowing you to use Block HTML caching and getting back some speed while enabling the fancy stuff.
Thanks for the heads-up on this one - I was struggling to figure out what was going on. Works on 1.3.2.4 too.
Regards,
Eddie
Signature
Web Design Leicestershire
Content Management Specialist
Posted: November 9 2010
| top
| # 11
ArashToro
Total Posts: 2
Joined: 2010-06-18
I just change my code to this and it works fine . Of course Flush the cach was needed. im using magento 1.4.1.1. There is no activation piece of code needed.
<?php $_menu = \\\'\\\'?>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
<?php if ($_menu): ?>
<div class=\\\"nav-container\\\">
<ul id=\\\"nav\\\">
<li class=\\\"level0 first nav-home\\\"><a href=\\\"<?php echo $this->getUrl() ?>\\\"><span><?php echo $this->__(\\\'Home\\\') ?></span></a></li>
<li class=\\\"level0 nav-1 parent\\\"><a href=\\\"<?php echo $this->getUrl(\\\'contacts\\\')?>\\\"><span><?php echo $this->__(\\\'Contact\\\') ?></span></a></li>
<?php echo $_menu; ?>
<?php echo $this->getLayout()->createBlock(\\\'cms/block\\\')->setBlockId(\\\'menu\\\')->toHtml() ?>
</ul>
</div>
<?php endif; ?>
Don’t forget to ignore this sign \\\ in the code.
if you want to put the contact menu after your home and product’s category menu. You should put your codes as follow:
<?php $_menu = ''?>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
<?php if ($_menu): ?>
<div class="nav-container">
<ul id="nav">
<li class="level0 first nav-home"><a href="<?php echo $this->getUrl() ?>"><span><?php echo $this->__('Home') ?></span></a></li>
<?php echo $_menu; ?>
<li class="level0 nav-1 parent"><a href="<?php echo $this->getUrl('contacts')?>"><span><?php echo $this->__('Contact') ?></span></a></li>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml() ?>
</ul>
</div>
<?php endif; ?>
Posted: December 3 2010
| top
| # 12