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.

Alternative to Channel as a variable inside a Conditional

December 15, 2010 5:41pm

Subscribe [3]
  • #1 / Dec 15, 2010 5:41pm

    Tyler Herman

    39 posts

    So I am trying to display channel entries from three different channels in an unordered list by comment_total which isn’t a problem. The problem is each set of entries is displayed in a different template group, so creating the link to each entry is proving difficult.

    {exp:channel:entries channel="posts|guides|news" limit="5" orderby="comment_total" status="featured|open" dynamic="off"}
                 <li><a href="http://{url_title_path=}">{title}</a><span>{entry_date format="%M %d, %Y"}</span> 
    {/exp:channel:entries}

    My original thought was to simply use the channel as a conditional variable so

    {if channel == "posts"}{url_title_path="posts/"}{/if}

    But that didn’t seem to work and I haven’t seen anywhere where channel is used as the variable in an if statement, so I assume that is not allowed. My second idea was to create a custom field for each entry and use that as the variable but I don’t really want to have to go into every entry and do that. I guess my other option would be to display all the entries in the same template group, but that would create duplicate locations and other headaches I would rather not deal with.

    Is there another way to do this I am not thinking of, is this not possible, or am I just doing it wrong.

  • #2 / Dec 16, 2010 4:17am

    John Henry Donovan

    12339 posts

    tgherman,

    Use the variable {comment_url_title_auto_path}
    that way the comment path will be picked up from each of your channels path preferences and added automatically.

    Let us know if that works for you

  • #3 / Dec 16, 2010 1:23pm

    Tyler Herman

    39 posts

    Yes that works perfectly. I must have skipped over that a dozen times cause it started with {comment, I didn’t think it was anything I was looking for. Turns out it is ridiculously useful.

    Thanks for the help.

  • #4 / Dec 16, 2010 6:00pm

    Ingmar

    29245 posts

    Glad to see John Henry was able to help. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases