Search code examples
expressionengine

URL title to Entry ID on Channel Entries tag


I'm trying to use the "URL title to Entry ID" plugin to feed the entry_id parameter into a Channel Entries tag, but can't figure out a way to get the ID information inserted early enough in the template parsing order.

This doesn't work - it picks up no entry ID, and so displays all entries:

{exp:channel:entries entry_id="{exp:url_title_to_entry_id parse="inward" url_title="{last_segment}"}" dynamic="no"}
{title}
{/exp:channel:entries}

Any suggestions would be much appreciated.


Solution

  • You can't have a function tag as a parameter to another function tag.

    So either you have to pass the {exp:url_title_to_entry_id} result as an embed variable to another template that holds the channel:entries tag, or you have to use tag pairs so that one function tag, wraps the other and uses variables.

    url_title_to_entry_id doesn't allow for tag pair, so either use the embed technique, or use another add-on.

    BUT, you don't need the add-on at all...

    {exp:channel:entries url_title="{last_segment}" dynamic="no"}
       {title}
    {/exp:channel:entries}
    

    reference.

    I'd also suggest added required_entry="yes" and limit="1" and then add {if no_results}...{/if} conditional inside. This will prevent it outputting all entries if it can't find a match.