0

I originally asked this question on stackoverflow, but was scolded a bit and rated down. I didn't realize there is now an entire Magento section, but now that I do this is clearly a more appropriate place to ask this question.

So, I know this is probably a simple question with an obvious answer... But my knowledge is pretty limited here. Anyway, all I'm trying to do is make the Product button I have in the top menu of my home page for my store link to a specific URL. So basically, right now, if you hover over the Products button you get a drop down of product categories (which is fine), but if you click on the actual Products button itself, it simply links back to the homepage. I'd like to link it to a Products landing page that I've created instead.

How do I achieve this? For reference, my site is: http://www.soundcherry.com.

The code that I THINK I need to edit is here: public_html/app/design/frontend/default/(the template I'm using)/template/catalog/navigation/top.phtml

And the code looks like:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<div class="nav-container">
<ul id="nav">
<li><a href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a></li>
<li><a href="<?php echo $this->getUrl('') ?>"><?php echo $this->__('') ?></a>
<?php if($_menu): ?>
    <ul>
        <?php echo $_menu ?>
    </ul>
<?php endif ?>
</li>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>

I'm not sure what to change, though. Or, even if this is the correct code to edit. Any help will be greatly appreciated!

  • Hi, I want to know, whether you have set product as a category in catalog->manage categories in admin . Also there should be a cms page with blockid = 'menu' in CMS -> Pages in admin. Can you show us content in it ? – Rajeev K Tomy Jun 13 '14 at 4:13
  • Hey there, thanks for taking the time to respond! No, I have not set product as a category in catalog>manage categories. Root is listed, and the sub categories of products are there, but that's it. As far as the cms pages, I don't see any with blockid = 'menu' in them. The standard pages as well as some I created are there (home, about, terms of service, 404, etc...) but that's it. Under CMS>Static Blocks there is a Menu, but it's content only includes the buttons I've added (FAQS, About, and Contact Us). – MAC Jun 13 '14 at 6:21
  • For reference, the Menu under static blocks in it's entirety looks like this: <ul> <li><a href="http://soundcherry.com/index.php/faqs/"><span>FAQs</span></a></li> <li><a href="http://soundcherry.com/index.php/about/"><span>About</span></a></li> <li><a href="http://soundcherry.com/index.php/contacts/"><span>Contact Us</span></a></li> </ul> – MAC Jun 13 '14 at 6:21
0

I don't know the page you want the Products menu item to point, but let's say that the page url identifier is products.
You need to change the line under the homepage link

<li><a href="<?php echo $this->getUrl('') ?>"><?php echo $this->__('') ?></a>

(I assume that in the line above <?php echo $this->__('') ?> should actually be <?php echo $this->__('Products') ?>).

to this:

<li><a href="<?php echo $this->getUrl('', array('_direct'=>'products')) ?>"><?php echo $this->__('Products') ?></a>
  • Hey Marius, thanks for your help. Unfortunately, I can't seem to get this to work. Basically, the page url identifier I'm using IS products, so I essentially used the full line of code you wrote exactly. When I do though, even after I clear the cache, nothing seems to change (the products button on my homepage still links back to home, and not to the products landing page I made). It's very possible I'm simply doing something wrong, since my knowledge is extremely limited here... I'm not sure. – MAC Jun 15 '14 at 0:06
  • It seems crazy that there's no simple way to change the URL that the Products button links to in Magento. It just seems odd that there wouldn't be a CMS static block in Admin with options for this... Instead, the "Menu" static block only contains additions to the menu... Not the original Products, or Home button. – MAC Jun 15 '14 at 0:17
  • @MAC. Make sure you are editing the right file. – Marius Jun 15 '14 at 7:11
  • Eureka! Got it. Thank you so much. The file I needed to modify was mentioned by programmer_rkt. It is located at: app/design/frontend/<your_package>/<your_theme>/template/page/html/topmenu.phtml Once I made your proposed modification, the Products button now links to my products landing page. Thanks so much for your help! – MAC Jun 16 '14 at 1:23
0

Use this code in your described file

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<div class="nav-container">
    <ul id="nav">
         <li><a href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a></li>
    <?php if($_menu): ?>
        <?php echo $_menu ?>
    <?php endif ?>
    </ul>
</div>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>

clear cache. Then check whether your menu works.

If that didn't work, try this

Location :app/design/frontend/<your_package>/<your_theme>/template/page/html/topmenu.phtml

<?php $_menu = $this->getHtml('level-top') ?>
<div class="nav-container">
    <ul id="nav">
         <li><a href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a></li>
    <?php if($_menu): ?>
        <?php echo $_menu ?>
    <?php endif ?>
    </ul>
</div>

and

Location : app/design/frontend/<your_package>/<your_theme>/template/catalog/navigation/top.phtml

 <?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
 <?php if($_menu): ?>
    <div class="nav-container">
       <ul id="nav">
          <?php echo $_menu ?>
       </ul>
    </div>
 <?php endif ?>
 <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>

Alos ensure that Catalog -> Manage Categories page has following tree-format

Your category tree should look like this

- Root Category(0)

    - Product(0)

        - Sound effects(67)
        - Music(56)
        - Ring Tones(45)
        - Packages(38)

Note: number provide inside () are not accurate. You dont need to care about it.

You may missing the the first-layer of sub-category and only have second-layer of sub category directly under root-category.

If that is the case, then create a subcategory with name Product and then add all other existing cateigories inside that subcategory and then try again.

Good Luck !!

  • Thanks for your help, programmer_rkt! Unfortunately, I still can't seem to get the products button to link to my products landing page. When I use the first piece of code you wrote in my described file (and clear the cache), the menu still seems to function fine. But, it appears that nothing has changed. As far as the Catalog > Manage Categories setup. I don't have a first layer category of "products." If I add one, and put the other categories into it, then I get a superfluous products choice in the drop down menu when I hover over my products button on the homepage. – MAC Jun 15 '14 at 0:10
  • Also, even if I add that products category, it's no problem for me to make a landing page for THAT (I can simply use a CMS static block for the landing page). BUT, the main products button on the homepage will still link back to home and not to my products landing page. I can't seem to get a configuration that works. I mean, really, if I could add a CMS static block for the root category, that might allow me to make a landing page that links to the products button. But, it doesn't appear to be possible to do that. – MAC Jun 15 '14 at 0:14

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.