We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How do I not show certain categories in the Photo Gallery Module?

Development and Programming

qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

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

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

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

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

That’s a good idea. I’ll try it.

Maybe this could be something added in a new update, because it seems like it would be pretty useful. Kind of odd that it isn’t included.

Thanks for the help.

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

I’m trying it but it doesn’t seem to work.

Is the “category_id” variable available in the “exp:gallery:category_list” tag? There’s no mention of it in the user guide, and it doesn’t seem to recognize it.

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

qruxart,

I apologize. We were looking at different tags. My bad.

Try switching category_id with cat_id and see if that makes a difference.

Jamie

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

No that didn’t work either. Hmmm.

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

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

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

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?

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

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

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

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?

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

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

       
qruxart's avatar
qruxart
20 posts
17 years ago
qruxart's avatar qruxart

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. 😊

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell
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.

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell
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.

       
Richard Frank's avatar
Richard Frank
200 posts
17 years ago
Richard Frank's avatar Richard Frank

Has anyone found any more solutions to this problem? I’m trying to exclude certain categories, and the above solution is not a long-term one (since you have to keep on adding conditionals every time someone adds a image gallery you don’t want to show).

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.