3

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?

AngryLaser
  • 33
  • 1
  • 5

2 Answers2

6

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.

rjb
  • 9,036
  • 2
  • 44
  • 49
  • In my EE 2.x MSM setup, in the main site the segment_3 rule is not applicable but the same is being enforced in another site I created using MSM. What is the reason behind this, if it is enforced in new site, then it should be in the default site as well? Advise? – djmzfKnm Jun 15 '16 at 09:27
3

ExpressionEngine looks at the segments which follow /index.php/ as the following:

  • the first segment is assumed to be the template group
  • the next segment is assumed to be the name of a template within that template group
  • the third segment is assumed to be either the url_title of an entry, or, if the segment is numeric, the entry_id of an entry

So, in your case, EE is looking to load the two template, from the one template group, and then display the entry from the my_channel channel that's in the category with the ID of 18 and has a url_title of three.

Your specification of the category only overwrites any category information in the URL. (e.g., /template_group/template/category/doorstops or /template_group/template/C10 would not affect which entries get displayed in your example).

If you want your {exp:channel:entries} tag to ignore the URL completely (with the exception of pagination), you can add dynamic="off" to your tag parameters.

Derek Hogue
  • 4,589
  • 1
  • 15
  • 27