ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Include Images from Sub-categories in gallery entries results

March 26, 2009 7:12pm

Subscribe [4]
  • #1 / Mar 26, 2009 7:12pm

    Ludwig Wendzich

    47 posts

    Hey Everyone;

    I am trying to create a list of newest images in gallery categories however I’d like all the images from the sub-category of any particular category to be included.

    For example I have:

    Category A
    —-Category C
    —-Category D
      —-Category E
    Category B

    I would like for when I specify category=“D” it shows images from D *and* E because E is a sub-category of D?

    Does that make sense?

    Cheers,
    Ludwig

    Moved to HowTo by Moderator

  • #2 / Mar 27, 2009 3:30am

    John Henry Donovan

    12339 posts

    Ludwig,

    I’m afraid that isn’t possible at the moment. You will have to pipe your parent and sub categories.

    category="D|E"

    You are welcome to make a Feature Request for it. A custom query would also do it. Something like below should work but would need tweaking.

    {exp:query sql="SELECT cat_id FROM exp_gallery_categories WHERE gallery_id= '1' AND parent_id= '3' ;"}
    
    {exp:gallery:entries gallery="{gallery_name}" orderby="entry_date" category="{cat_id}|3"}
    
    {entries}
    
    {row}
    
    <a href="http://{id_path=gallery/image_med}">{image_url}</a>
    <div class="title">{title}
    
    {/row}
    
    {/entries}
    {/exp:gallery:entries}
    {/exp:query}
  • #3 / Mar 27, 2009 3:52am

    Ludwig Wendzich

    47 posts

    Won’t that create multiple requests asking for the latest in D and E and then D and F and then D and G which means D gets repeated for each sub-album. Ie, it creates multiple queries instead of combining them into one?

    Anyway, this code is just not displaying anything :

    {exp:query sql="SELECT cat_id FROM exp_gallery_categories WHERE gallery_id='1' AND parent_id='{embed:ministry_gallery}' ;"}
    {exp:gallery:entries gallery="photos" category="{cat_id}|{embed:ministry_gallery}" orderby="date" columns="5" rows="2" dynamic="off"}
    <li><a href="http://{id_path=photos/photo}cat/{category_id}">{thumb_url}</a></li>
    {/exp:gallery:entries}
    {/exp:query}
  • #4 / Mar 27, 2009 4:01am

    John Henry Donovan

    12339 posts

    Ludwig ,

    You are missing some of my example code, specifically the {entries} and {row} tag and you have orderby=“date” rather than orderby=“entry_date”

    {exp:query sql="SELECT cat_id FROM exp_gallery_categories WHERE gallery_id='1' AND parent_id='{embed:ministry_gallery}' ;"}
    {exp:gallery:entries gallery="photos" category="{cat_id}|{embed:ministry_gallery}" orderby="entry_date" dynamic="off"}
    
    {entries}
    
    {row}
    
    <li><a href="http://{id_path=photos/photo}cat/{category_id}">{thumb_url}</a></li>
    
    {/row}
    
    {/entries}
    {/exp:gallery:entries}
    {/exp:query}
  • #5 / Mar 27, 2009 4:22am

    Ludwig Wendzich

    47 posts

    Oh! I now see pictures but as I feared the images from Category D are being repeated for each sub-category under it.

  • #6 / Mar 27, 2009 11:50am

    Ingmar

    29245 posts

    Ludwig, are there some unresolved Tech Support issues left? If you want to discuss the in some more depth, I can move the thread over to Howto. Otherwise (or in addition), I’d suggest a Feature Request.

  • #7 / Mar 27, 2009 4:46pm

    Ludwig Wendzich

    47 posts

    Ingmar, I guess this needs to continue as a How-to?

    Thanks!

  • #8 / Mar 27, 2009 5:00pm

    Sue Crocker

    26054 posts

    Moving..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases