Page 1 of 1

[SOLVED]Remove drop down sub-category on top menu bar

Posted: Tue Jan 20, 2015 2:55 am
by akewq
Hello Guys,
I would like to know how to remove drop down sub-category on top menu bar.

Please help.

Thanks!

Re: Remove drop down sub-category on top menu bar

Posted: Tue Jan 20, 2015 9:38 am
by fido-x
In the header template file (catalog/view/theme/default/template/common/header.tpl, starting at lines 88 to 119, you will find the following code:

Code: Select all

<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <?php foreach ($categories as $category) { ?>
        <?php if ($category['children']) { ?>
        <li class="dropdown"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>
          <div class="dropdown-menu">
            <div class="dropdown-inner">
              <?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>
            </div>
            <a href="<?php echo $category['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $category['name']; ?></a> </div>
        </li>
        <?php } else { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
        <?php } ?>
      </ul>
    </div>
  </nav>
</div>
<?php } ?>
Replace with:

Code: Select all

<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <?php foreach ($categories as $category) { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </nav>
</div>
<?php } ?>

Re: Remove drop down sub-category on top menu bar

Posted: Wed Jan 21, 2015 12:58 pm
by akewq
fido-x wrote:In the header template file (catalog/view/theme/default/template/common/header.tpl, starting at lines 88 to 119, you will find the following code:

Code: Select all

<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <?php foreach ($categories as $category) { ?>
        <?php if ($category['children']) { ?>
        <li class="dropdown"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>
          <div class="dropdown-menu">
            <div class="dropdown-inner">
              <?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>
            </div>
            <a href="<?php echo $category['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $category['name']; ?></a> </div>
        </li>
        <?php } else { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
        <?php } ?>
      </ul>
    </div>
  </nav>
</div>
<?php } ?>
Replace with:

Code: Select all

<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <?php foreach ($categories as $category) { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </nav>
</div>
<?php } ?>
Thanks for the reply!
For some reasons the codes doesn't work.

Re: Remove drop down sub-category on top menu bar

Posted: Wed Jan 21, 2015 6:39 pm
by fido-x
Do you have any OCMODs that might be modifying the header template file? If so, you will need to clear your modification cache and refresh (under Extensions->Modifications in the admin).

Re: Remove drop down sub-category on top menu bar

Posted: Thu Jan 22, 2015 1:44 am
by akewq
fido-x wrote:Do you have any OCMODs that might be modifying the header template file? If so, you will need to clear your modification cache and refresh (under Extensions->Modifications in the admin).
Thanks!! Perfect!!

By the way, do you know how to sub-categories show on my left to show... I mean always show, not after i clicked on the parent category. I have tried searching this on the forum, no luck.

Please help.

Thanks!

Re: [SOLVED]Remove drop down sub-category on top menu bar

Posted: Wed Feb 06, 2019 3:31 am
by Fuzzy
Thank you for this post.

I am using opencart version 3.0.2

I was just wondering if this will work for this version as well.

Thanks.