Search code examples
expressionenginechannelsegments

When I add a third segment to my expressionengine url, the exp:channel:entries stops returning results


I'm having an issue where a third "segment" in the url will cause ALL the exp:channel:entries to stop returning results.

Example URLs:
works fine: siteurl.com/index.php/one/two
does not work: siteurl.com/index.php/one/two/three

Example Entry Pull:
{exp:channel:entries channel="my_channel" category="18" sort="asc" search:show_toggle="=SHOW" orderby="sort_order"}

Is this some kind of injection that I am unaware of. I have searched through the documentation, and from what I can tell my specification of a category should overwrite anything in the url. I may be botching it up, but there HAS to be something I can do.? Something I can modify in the channel module?


Solution

  • Without using the dynamic tag parameter in your Channel Entries tag, ExpressionEngine is expecting a URL Segment Variable to contain the Entry ID or URL Title of your entry.

    Since the third URL Segment /index.php/one/two/three isn't a numeric Entry ID or URL Title, your Channel Entries query doesn't contain any information.

    By setting dynamic="no" you will ensure that the list is not affected by anything passed in the URL.

    Since you've written an extremely specific Channel Entries Query, be sure to add dynamic="no" to your {exp:channel:entries} tag loop to have ExpressionEngine ignore the URL Segments and instead use the parameters you supply:

    {exp:channel:entries channel="my_channel" dynamic="no" ...}
        ...
    {/exp:channel:entries}
    

    Furthermore, by adding a simple Conditional Variable to your code, you will be able to see a message when no results are returned:

    {exp:channel:entries channel="my_channel" ... }
        {if no_results}Sorry, No Results{/if}
    
        ...
    {/exp:channel:entries}
    

    Grokking the fundamental ExpressionEngine's URL concepts and URL Segments is important to understanding and troubleshooting issues like this.