On my single-entry page template, I have two places where I call in the channel content. In the title, I use
<title>{exp:channel:entries channel="{my_channel}" disable="categories|category_fields|custom_fields|member_data|pagination"}{title}{/exp:channel:entries}</title>Then in the body of the page I use the same thing, except without the disable parameter, to display my content. E.g:
{exp:channel:entries channel="{my_channel}"}<h1>{title}</h1>{body}{/exp:channel:entries}I’ve discovered that if I add require_entry=“yes”, followed by {if no_results}{redirect="404"}{/if} on the 2nd {exp:channel:entries} tag (in the body of my HTML page), then when I type in an invalid URL, I get the 404 page returned, but with PHP errors at the top:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
Filename: libraries/Template.php
Line Number: 1377
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
Filename: libraries/Template.php
Line Number: 1378If I add require_entry=“yes”, followed by {if no_results}{redirect="404"}{/if} on the 1st {exp:channel:entries} tag (in my HTML title), typing in an invalid URL successfully returns my 404 page without any errors.
<title>{exp:channel:entries channel="{my_channel}" disable="categories|category_fields|custom_fields|member_data|pagination" require_entry="yes"}{if no_results}{redirect="404"}{/if}{title}{/exp:channel:entries}</title>This is just a cosmetic thing (I’d prefer not to have all the conditional logic in my HTML title). I’m fairly sure in the past I could have two {exp:channel:entries} tags in the same template, and put the require_entry/if_no_results code in either instance and it would work.
I wanted to post here first in case this was already reported in a way I didn’t find…this may be related to this thread in the archived forums: http://ellislab.com/forums/viewthread/154074 but this thread didn’t seem to lead to a bug report that I could find.
(PS: My 404 page is defined!)