Image gallery - filtering results based on category

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 11, 2016   (RSS)

By superhappybunnycat - November 9, 2016 - edited: November 9, 2016

I am trying to create an image gallery that has a main category, and a list of sub items underneath each e.g.

The Lilac Ball
- 2016
- 2015

News and Media
- Something
- Something else

On the gallery page, I want to list the main categories only, and then when you click on that link you will see the items under it eg

>> on main gallery page

The Lilac Ball
News and Media

>> Once you have clicked on one of the above, The Lilac Ball for example you'd see:

2016
2015


I've created 2 sections in CMBS. Gallery categories (the main category) and Gallery.

GC is a list of category names that I am pulling into a dropdown field in the Gallery section. This is so the website owner can add new categories later themselves.

I have created a gallery page that lists the gallery categories (using the gallery section, not the GC section) and then added the link. I also created a list page for the gallery section to list all the items. It is currently not working though and is listing all of the items from every category no matter what you click on.

Can anyone give me a heads up to the code I'm missing? I thought I could append something like category_keyword=The%20Lilac%20Ball to the URL but that didn't work either. Ideally it would be done dynamically in the page because I'd like the site owner to be able to add new categories without me having to make updates for them

Here are my pages so far:
http://www.thenelunefoundation.org/new/gallery.php
http://www.thenelunefoundation.org/new/gallery_.php

If the title on gallery_.php could also update to whatever category you had clicked on, that would be awesome but if it's too tricky it's no biggy

By ross - November 10, 2016

Hi there.

Thanks for posting

Could you post a copy of both your pages (not just a link to them) so I can review the code?

Also, if you know how, could you post a copy of the schema files for your two sections. They will be in /data/schemas/.  Having the schemas gives me more options on narrowing everything down. The schemas aren't required though so if it doesn't work to post them, don't worry; I can still work with just the pages.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By ross - November 11, 2016

Thanks for posting your files.

I have two recommendations.

1. On your gallery_.php page, look for 

'allowSearch' => false,

and change it to:

'allowSearch' => true,

That will let you link to gallery_.php with variables in the URL like: gallery_.php?gallery=gallery

2. In your gallery schema, change the "Use this field for option values" for your "Category" drop down to "num" instead of title. This change gets made in CMS Builder (don't just edit your schema).

That should get you sorted out.

Let me know how you make out.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Fantastic! I updated the link code for the gallery categories to the below and now it all works perfectly. Thanks for your help :)

<?php foreach ($gallery2Records as $record): ?>
<li><a href="gallery_.php?category=<?php echo $record['category'] ?>"><?php echo $record['category'] ?></a></li>
<?php endforeach ?>