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.

Custom Field for Category

September 30, 2011 9:13am

Subscribe [3]
  • #1 / Sep 30, 2011 9:13am

    Hi. I need to add a custom field to a channel so my client can choose a category. The object of this is to get the category ID to use the category_group=”” tag to display only images from a specific category of the users choice.

    How would I achieve this?

    Thanks 😊

  • #2 / Sep 30, 2011 3:13pm

    Rob Allen

    3114 posts

  • #3 / Sep 30, 2011 10:09pm

    Dan Decker

    7338 posts

    Chris,

    Did Rob’s suggestion help you out?

  • #4 / Oct 03, 2011 6:00am

    Hi. I am still having some difficulty.

    I am trying to pull in data into the a channel entries tag. I am starting to wonder if its possible.

    I am using the add on above, it pulls in the category id.

    Here is the code I have:

    {exp:channel:entries channel="workshops"}
    
    {exp:channel:entries channel="gallery" limit="6" dynamic="no" category="{images_category}"}
    
    <li class="{switch='workshop_first|workshop_second'}">
    
    {exp:ce_img:pair src="{gallery_image}" width="120" height="100" crop="yes"}
    <a href="http://{title_permalink=gallery/view}">{made}</a>
    {/exp:ce_img:pair}
    
    </li>
    
    {/exp:channel:entries}
    
    {/exp:channel:entries}

    Is this possible?

    Thanks

  • #5 / Oct 03, 2011 5:00pm

    Dan Decker

    7338 posts

    Chris,

    Oh… I see. You can’t nest {exp:channel:entries} like that, at least it’s not advisable. However, you could achieve this by passing along your variable to an embedded template:

    {exp:channel:entries channel="workshops"}
    
    {embed="embed_template" pass_image_category="{images_category}"}
    
    {/exp:channel:entries}

    and then in your embedded template:

    {exp:channel:entries channel="gallery" limit="6" dynamic="no" category="{pass_image_category}"}
    
    <li class="{switch='workshop_first|workshop_second'}">
    
    {exp:ce_img:pair src="{gallery_image}" width="120" height="100" crop="yes"}
    <a href="http://{title_permalink=gallery/view}">{made}</a>
    {/exp:ce_img:pair}
    
    </li>
    
    {/exp:channel:entries}

    Let us know if you have any questions.

    Cheers,

  • #6 / Oct 04, 2011 4:25am

    Hi Dan

    Thank for your reply.

    I have tried the approach you recommend but it isn’t working.

    The embed works if I put a category=”” manually in, so I know its embedding correctly. I also know that the {images_category) is bringing in the category id correctly.

    {exp:channel:entries channel="workshops"}
    
    {embed="workshops/images_embed" pass_image_category="{images_category}"}
    
    {/exp:channel:entries}

    However, in the embed, it still isnt working.

    {exp:channel:entries channel="gallery" limit="6" dynamic="no" category="{pass_image_category}"}
    
    <li class="{switch='workshop_first|workshop_second'}">
    
    {exp:ce_img:pair src="{gallery_image}" width="120" height="100" crop="yes"}
    <a href="http://{title_permalink=gallery/view}">{made}</a>
    {/exp:ce_img:pair}
    
    </li>
    
    {/exp:channel:entries}

    It just displays nothing. In firebug it just shows an empty html tag. If I manually place in a category id it works.

    Am I missing something?

    Thanks

  • #7 / Oct 05, 2011 6:23am

    Anyone have any ideas?

  • #8 / Oct 05, 2011 4:34pm

    Dan Decker

    7338 posts

    Chris,

    Sorry to keep you waiting try this in your embed template:

    {exp:channel:entries channel="gallery" limit="6" dynamic="no" category="{embed:pass_image_category}"}

    Cheers,

  • #9 / Oct 06, 2011 2:37am

    No problem Dan! It worked perfectly this time. Thanks for your support.

  • #10 / Oct 08, 2011 9:24pm

    Dan Decker

    7338 posts

    Chris,

    I’m glad I could provide assistance. If you run into any trouble in the future, let us know by starting a new thread.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases