Post by ShaneTFletcher » Mon Oct 29, 2012 4:41 pm

Short and simple -

How do I remove the auto-hide on the menu when there is no category placed in the menu bar?

Thanks
Last edited by ShaneTFletcher on Wed Oct 31, 2012 8:34 pm, edited 1 time in total.

New member

Posts

Joined
Sat Jul 07, 2012 4:32 am

Post by labeshops » Mon Oct 29, 2012 8:58 pm

Edit your template common/header.tpl

at the bottom find

Code: Select all

<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
       <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
Remove the top most and bottom most line from the above. You are removing the if statement to check to see if there are any categories set to display at top so they always display.

Running Opencart v2.2 with multi-stores from https://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by ShaneTFletcher » Mon Oct 29, 2012 11:00 pm

That's what I thought but deleting them lines only deletes the menu altogether.

I've basically used the HTML coding from the menu and customized it. Meaning when category is placed and 'top' option is ticked, the link will not store on the menu.

The reason I am doing this is because I do not want sub-categories to show on the menu (drop down) but when I delete the piece for code to stop this, problems just occur! So with custom made links, I can simply click and no worry about any drop down menus. On the other hand, I want to add maybe a category without entering some line of code every time.

New member

Posts

Joined
Sat Jul 07, 2012 4:32 am

Post by labeshops » Tue Oct 30, 2012 12:10 am

If you want to remove children categories and have it display all the time, replace the entire section I posted above to:

Code: Select all

    <div id="menu">
      <ul>
        <?php foreach ($categories as $category) { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
        <?php } ?>
      </ul>
    </div>
and it should do what you want. Make sure you clear all caches, including vqmod if you use it.

I manually code all my menus so I can change them for each of my multistores including the category name for seo purposes which is a bit of a pain if I decide to add a category later, but this is rare in my case at least.

Running Opencart v2.2 with multi-stores from https://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by ShaneTFletcher » Wed Oct 31, 2012 8:33 pm

Perfect!

Thanks labeshops!

New member

Posts

Joined
Sat Jul 07, 2012 4:32 am

Post by labeshops » Thu Nov 01, 2012 12:09 am

No problem :)

Running Opencart v2.2 with multi-stores from https://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA
Who is online

Users browsing this forum: No registered users and 19 guests