I’m using the Gallery Category List Tag as a way to navigate through my categories. I would like to have it only show certain categories but I cannot figure out how to do it. This would seem like the best way to do it but it’s not available:
<ul id="nav_main">
{exp:gallery:category_list gallery="{gallery_name}" category="not 13"}
<li><a href="http://{category_path={my_template_group}/set}">{category_name}</a></li>
{/exp:gallery:category_list}
<li id="more_info"><a href="#">Bio</a>
<a href="#">Contact</a>
<a href="#">Home</a></li>
</ul>
Using this format would be nice too but this is not available either:
{exp:gallery:categories gallery="GALLERY_NAME" category="not 13"}<li><a href="http://{category_path={my_template_group}/set}">{category_name}</a></li>{/exp:gallery:categories}
Is their any other way you would suggest for making this possible?
thanks
The exp:gallery:categories tag only has one parameter “gallery”. So you can’t do it the way you are trying to.
You could have a conditional within the tags that removes that category.
It is a little more clunky but it would work:
<ul id="nav_main">
{exp:gallery:category_list gallery="{gallery_name}"}
{if category_id != "13"}
<li><a href="http://{category_path={my_template_group}/set}">{category_name}</a></li>
{/if}
{/exp:gallery:category_list}
<li id="more_info"><a href="#">Bio</a>
<a href="#">Contact</a>
<a href="#">Home</a></li>
</ul>
Jamie
hehe,
Ok, I’m going to tell you to do something I normally would not do. But in this case after looking at the code I don’t think it will be an issue in this case.
Make the conditional we added look like this:
{if "{cat_id}" != "13"}
Note the quotes and curly brackets around the cat_id variable.
Don’t ever do this anywhere else, ever again.
It is generally a very inadvisable thing to do because of the fact that quotes are very easy to break with content that might contain quotes or line breaks or other messy stuff. But in this case we know the cat_id value under any normal conditions is always going to be a number and there “shouldn’t” be a way for that to not be the case.
Jamie
Ok that does work in fact. Very tricky!
Now since this did work I’m trying to also not show any subcategories of that particular category. Is there something similar for subcategories?
What I’m trying to do is have an “archive” photo gallery category. Photos that I don’t want to have displayed in the main navigation categories, I want moved to an “archive category”, basically a category called “archive” with subcategories under it. This way I can easily move photos into the archive by applying an archive subcategory.
With this in mind I want the main nav to just show “active” categories. The archive category will show up as a link elsewhere in the navigation structure. This will then take you to a page that has just a list of all the subcategories of “archive”, minus the “active” categories. Does this make sense? I’m using the code you gave me to remove the archive category from the main nav, but I was hoping it would also remove the subcategories. I’ve tried this bit of code in the meantime but I’m having a problem trying to have it not show the subcategories.
{exp:gallery:categories gallery="{gallery_name}"}
<ul id="nav_main">
{category_row}
{row}
{if category_id != 13}
<li><a href="http://{category_path=photography/index}">{category}</a></li>
{/if}
{/row}
{/category_row}
{if subcategory_row }
{subcategory_row}
{row}
{/row}
{/subcategory_row}
{/if}
<li id="more_info"><a href="#">Bio</a>
<a href="#">Contact</a></li>
</ul>
{/exp:gallery:categories}
This seems to work exact I can’t make the subcategories disappear. Any ideas?
I can’t help you there. The parent_id is not available within that tag in any form.
You seem to need some very specific functionality here. I’m wondering if a query using the query module or else even a plugin might not be a better solution for you. How comfortable are you with SQL and/or PHP?
Jamie
I’m not comfortable with either of those unfortunately.
Can you tell me how to write a conditional that checks if subcategory_row exists don’t show anything?
The code I used above with the {exp:gallery:categories} tag does work and it will show anything I put between the {if category_row} conditional but I’m trying to figure out how to do it using the same logic you used: if category_id != x show the code.
Maybe something like this
{if subcategory_row == ""}{/if}
Any ideas?
You are switching tags on me here. 😊 I didn’t notice that first time around.
If you are using that tag you have a category_id variable to work with. So why not just remove the “archive” category by using this conditional:
{if category_id != "13"}
Stuff you don't want done for archive category.
{/if}
Jamie
I tried that but that didn’t seem to work quite right either.
So I came up with this and it seems to work.
{exp:gallery:categories gallery="{gallery_name}"}
<ul id="nav_main">
{category_row}
{row}
{if category_id != 13}
<li><a href="http://{category_path=photography/index}">{category}</a></li>
{/if}
{/row}
{/category_row}
{if subcategory_row}
{subcategory_row}
{row}
{blank}
{/row}
{/subcategory_row}
{/if}
<li id="more_info"><a href="http://{path=photography/archive}">Archive</a>
<a href="#">Bio</a>
<a href="#">Contact</a></li>
</ul>
{/exp:gallery:categories}
Where the global variable {blank} is just a space. It’s a bit of a hack but it seems to work. Now it’s on to the archive page and reversing the whole procedure. Yikes!!
Thanks for all your help. I may be posting to this thread again if I run across issues on the archive page. 😊
I can’t help you there. The parent_id is not available within that tag in any form. You seem to need some very specific functionality here. I’m wondering if a query using the query module or else even a plugin might not be a better solution for you. How comfortable are you with SQL and/or PHP? Jamie
I have a plugin that gets the parent_id and does a few other things. I will see if I can work this functionality into it.
Now since this did work I’m trying to also not show any subcategories of that particular category. Is there something similar for subcategories? What I’m trying to do is have an “archive” photo gallery category. Photos that I don’t want to have displayed in the main navigation categories, I want moved to an “archive category”, basically a category called “archive” with subcategories under it. This way I can easily move photos into the archive by applying an archive subcategory.
That is pretty easy to do with a simple query to find all sub-cats of a particular category.
When I have a moment I will post some code.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.