EE 2.1.4 build 20110201
I am getting unexpected behavior from require_entry, and I was hoping you could shed some light on it for me.
I am trying to pass a url_title as part of my URL.
http://example.com/ee.php/about-us/
I’ve configured the general settings so that http://example.com/ is my “root” folder and “ee.php” is my index file. The following code exists inside my “home” template (the one EE uses as the site root).
This code works:
{exp:channel:entries url_title="{last_segment}"}
{title} - {url_title}
{/exp:channel:entries}This code does not work (the title - url_title is not displayed) even though the entry does indeed exist:
{exp:channel:entries url_title="{last_segment}" require_entry="yes"}
{title} - {url_title}
{/exp:channel:entries}The same URL is used for both code samples. Why does the second approach fail?
I dug into the codebase to look for clues. I added echo statements to mod.channel.php on line 1397:
echo "[" .$qstring . "]";
$xe = explode('/', $qstring);
$qstring = current($xe);
echo "[" .$qstring . "]";The output is this:
[ee.php/about-us][ee.php]mod.channel.php then proceeds to look for an article with the url_title “ee.php”, which of course does not exist.
1) Why does require_entry only look at the very first segment and not each one? My best guess is that $qstring is supposed to have been modified in some way previous to this code line and the ee.php segment stripped, but that’s not happening for me.
2) Why do you suppose I am seeing this behavior? Have I misconfigured something?
I would prefer to use require_entry because it elegantly handles cases where url_title={last_segment}” does not produce a legitimate entry. If I use the first code example then a blank last_segment returns all entries in that channel, which is not ideal.
Thanks in advance for your help! This one’s got me puzzled.