Page 1 of 1
limit categories in the header
Posted: Fri Jul 29, 2011 6:17 pm
by aaron1988
Hi everyone i have the categories in my header and of course on the left, how can i limit the categories in my header so it only display say the first 8 or 9 and then it adds the rest to the categories on the left? the code in my header is this: Also Opencart Version using 1.5.1.1
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 } ?>
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Fri Jul 29, 2011 7:26 pm
by teratyke
I know its not exactly answering your question, but did you know that you can choose which top level categories appear in the header in the admin by clicking "Top"?
This doesn't stop them appearing in your left category navigation though.
Perhaps you could check for the top attribute in the category module and exclude any categories which have it selected - that would make the header categories and the "left" categories mutually exclusive. Sorry I don't have the code to do that.
Rob
Re: limit categories in the header
Posted: Fri Jul 29, 2011 7:26 pm
by uksitebuilder
easy way is to only select/tick the 'Top' radio button when adding/editing categories for those categories you want to display in the top menu bar
Re: limit categories in the header
Posted: Fri Jul 29, 2011 11:49 pm
by aaron1988
Awwww ok i will try this
Thanks for reply
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Sat Jul 30, 2011 2:07 am
by aaron1988
Thanks, thats exactly what i needed

,
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Wed Aug 17, 2011 2:28 am
by tilesupply
How can I set the categories that are in the top menu not to show in the left categories box and only show the ones in the left that are not in the top menu.
Kind Regards
Re: limit categories in the header
Posted: Wed Aug 17, 2011 4:58 am
by aaron1988
All i believe you can do at the moment is Display all the categories on the left and choose which categories appear on the top. i not seen a way to do what you need but maybe soneone else could help on this with more knowledge.
Aaron
Re: limit categories in the header
Posted: Wed Aug 17, 2011 5:37 am
by uksitebuilder
It would require editing core code or using vQmod to create an override
Basically you would need to edit the category module controller to not add to the data array if top = 1
And also omit it's children.
Re: limit categories in the header
Posted: Wed Aug 17, 2011 6:19 am
by tilesupply
What would the code need to be changed to.
I did have a go but lets just say i donk know the code that well.
If I know what the code is I will make a VQmod and give it as a Free Contributions.
As this is sending me a bit nuts trying to get it to work.
uksitebuilder wrote:It would require editing core code or using vQmod to create an override
Basically you would need to edit the category module controller to not add to the data array if top = 1
And also omit it's children.
Re: limit categories in the header
Posted: Thu Aug 18, 2011 3:15 pm
by aaron1988
Hey i will look this morning and see if i can find it for you

.
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Thu Aug 18, 2011 8:58 pm
by tilesupply
Many Thanks
aaron1988 wrote:Hey i will look this morning and see if i can find it for you

.
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Thu Aug 18, 2011 9:06 pm
by uksitebuilder
open: catalog/controller/module/category.php
find:
Code: Select all
foreach ($categories as $category) {
add after:
find:
Code: Select all
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
before add:
Re: limit categories in the header
Posted: Thu Aug 18, 2011 9:54 pm
by aaron1988
And it 100% Works
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Fri Aug 19, 2011 12:39 am
by aaron1988
No Problem mate
thats what we are here for to help the community

, if i can help i will but my knowledge isn't that great on php but i am better at debugging lol
Kind Regards,
Aaron
Re: limit categories in the header
Posted: Fri Aug 19, 2011 3:28 am
by tilesupply
Thanks to uksitebuilder for the code and here is the vqmod to change the core file without messing with the core files.
http://forum.opencart.com/download/file ... ew&id=6716
Many Thanks
Paul
uksitebuilder wrote:open: catalog/controller/module/category.php
find:
Code: Select all
foreach ($categories as $category) {
add after:
find:
Code: Select all
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
before add:
Re: limit categories in the header
Posted: Wed Aug 24, 2011 1:27 pm
by kaylamatthews
uksitebuilder wrote:open: catalog/controller/module/category.php
find:
Code: Select all
foreach ($categories as $category) {
add after:
find:
Code: Select all
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
before add:
As usual, after searching for a while here, you save the day! Thanks so much!
Re: limit categories in the header
Posted: Thu Feb 09, 2012 11:35 pm
by jg_hill
I am looking for something similar:
I have a set of top-level categories that I show in the header (using the Top checkbox)
I need to be able to exclude/hide a subset of those categories in the side module.
For example, my header row includes a Contact Us link that I don't want shown in the list of categories down the side.
Using 1.5.1.3 with VQMod
Any help would be appreciated.
Re: limit categories in the header
Posted: Mon Sep 03, 2012 3:28 am
by Viacheslav
Hello, I'm using OpenCart 1.5.4.1 and this xml file doesn't work in this version.The solution for hiding from the sidebar (Display in the top menu bar) doesn't do anything.
Is there is a way to make it work in 1.5.4.1 ?
Re: limit categories in the header
Posted: Thu Dec 20, 2012 2:49 am
by ThuNderGr
jg_hill wrote:I am looking for something similar:
I have a set of top-level categories that I show in the header (using the Top checkbox)
I need to be able to exclude/hide a subset of those categories in the side module.
For example, my header row includes a Contact Us link that I don't want shown in the list of categories down the side.
Using 1.5.1.3 with VQMod
Any help would be appreciated.
same problem here....
i used a vqmod to add a link to a category and dislay it on the top menu. However it also displays in category module.
any ideas on how to exclude that specific pseudo-category from showing up in category module?
Re: limit categories in the header
Posted: Fri Oct 04, 2013 10:26 pm
by alvin101
This looks like a great mod... Trying to use os in part as a cms to host some general information pages... I would need a menu which links to these pages.
So I think I can use Categories for this, but I would want to separate the product categories form the info categories, this module will do that... unless someone has a better idea?
So I have the top as product category, and the side as info category,..
Now I would like to change the name on this menu from Categories to something like Product Info,
Is there an easy way to do this?
Please inform, Thanks