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.

Getting Dynamic Category on Page

February 17, 2012 8:41pm

Subscribe [2]
  • #1 / Feb 17, 2012 8:41pm

    Charming Nerd

    196 posts

    My client is going to be creating entries with custom field content. But on the same page will be listings from another channel in a particular category. I am looking for options but I was thinking of making them choose from the same list of categories. If I can get the id of the category associated with the PAGE they are viewing and then assign it to the channel entries category= parameter I could pull this off. Here is some example code:

    {exp:channel:entries channel="trip_type_pages" limit="1" status="open|Archived" disable="comments|trackbacks"}
    
       <h1>This is inside trip_type_pages.</h1>
       
       That means I have access to any custom field data associated with this entry based on the URL. For example:
       
       The title of this page = {title}
    
    {/exp:channel:entries}
    
    
    <h1>Below are channel listings from another channel based on the category that the above entry is in.</h1>
    
    {exp:channel:entries channel="trips" category="NEED DYNAMIC CATEGORY HERE" dynamic="off" status="open" orderby="trip_dates" sort="asc" disable="comments|trackbacks"}
                    
     {title}
                        
    {/exp:channel:entries}

     

    Or if there is another way to go about this, I am all ears.

    I thought about using Playa, but that means they would have to select the individual entries by hand. If a new entry was added, they would have to go back to the page and update it manually.

     

     

  • #2 / Feb 18, 2012 5:28am

    Mark Bowen

    12637 posts

    I might be wrong here but it sounds like you might be trying to show in your second Channel Entries tag, entries which are in the same category(ies) as the single entry that you are displaying on that page already?

    If so then take a look at the related_categories_mode=“yes” parameter as I believe that will enable you to do what you need here.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / Feb 18, 2012 4:53pm

    Charming Nerd

    196 posts

    it isn’t working for me for some reason. Here is what I got:

    {exp:channel:entries channel="trip_type_pages" limit="1" status="open|Archived" disable="comments|trackbacks"}
    
       <h1>Channel="trip_type_pages"</h1>
       
       That means I have access to any custom field data associated with this entry based on the URL. For example:
       
       The title of this page = {title}
    
    {/exp:channel:entries}
    
    
    
    
    
    <h1>These should be listings from channel="trips" based on the category that the above entry is in.</h1>
    
    {exp:channel:entries channel="trips" dynamic="yes" related_categories_mode=“yes” status="open" orderby="trip_dates" sort="asc" disable="comments|trackbacks"}
                    
     {title}
                        
    {/exp:channel:entries}


    Auto-Assign Category Parents are set to No

    noting is showing up for the trip listings.


    Here is my test page. I set the URL in the Pages module and chose the template with the code you see above.
    http://arcc.clientwebreview.com:9999/service-adventures/

     

     

     

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

ExpressionEngine News!

#eecms, #events, #releases