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.

Need some help understanding title_permalink

March 14, 2011 1:46pm

Subscribe [3]
  • #1 / Mar 14, 2011 1:46pm

    ggoforth

    119 posts

    Hello all, not really having an issue, just trying to understand how something is working.  I’m creating a blog for my EE site, so I have a channel called “blog”.  The custom fields I have for the channel are “content” and “summary”.  If there is a summary entered for the record, I’m outputting that, as well as a “Read More” link created with “title_permalink”.  I’m using “blog/article/name-of-article” style title_permalinks.  My blog/article template is the exact same as the blog/index.  When I go to the blog/article template, it just works!  This is great, I’m just trying to understand how the proper article is being selected, as both templates use:

    {exp:channel:entries channel='blog'}
    {title}
    ....
    {/exp:channel:entries}

    Thanks for any insights anyone can offer.

  • #2 / Mar 14, 2011 2:47pm

    Kevin Cupp

    791 posts

    It’s just magic! But seriously, take a look at the “dynamic” parameter of {exp:channel:entries}:

    http://ellislab.com/expressionengine/user-guide/modules/channel/parameters.html#par_dynamic

    Basically, by default, EE will use the URL to determine what to show if there is relevant info in there, in this case it’s the {url_title} it sees. It can also cause problems sometimes depending on how you want to display data, so in that case, set dynamic=“no”.

  • #3 / Mar 14, 2011 2:53pm

    ggoforth

    119 posts

    Awesome, thanks Kevin.  So the code used to display a single entry still requires the:

    {exp:channel:entries channel='blog'}
    ...
    {/exp:channel:entries}

    Just wasn’t sure if those variables (like {title} or {author}) are available without needing the looping structure.

  • #4 / Mar 14, 2011 2:58pm

    Kevin Cupp

    791 posts

    Yep that’s all you need, all your channel variables should work just fine. Though I would change it slightly to make sure it only shows what it’s supposed to and redirects to a 404 if nothing is found:

    {exp:channel:entries channel='blog' require_entry='yes' limit='1'}
    {if no_results}{redirect='404'}{/if}
    ...
    {/exp:channel:entries}
  • #5 / Mar 14, 2011 3:00pm

    ggoforth

    119 posts

    Done and done.  Thanks for the help and good suggestions!

  • #6 / Mar 15, 2011 6:00am

    John Henry Donovan

    12339 posts

    Thanks Kevin. Feel free Greg, to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases