2

I have a template set up that I point various Channel Entries to via a pages URL. For example, I might have a channel on my site that contains all the various pages for a department, and all those channel entries point to a single template. That template, of course, shows whatever channel entry gets pumped its way.

I'm noticing that I'm never getting a 404 when an invalid URL is typed in; the template just serves a piece of content off the stack from the channel. So if I go to /whatever/labs I'll see the content I expect there. If I go to /whatever/labsARG I'll see some random content pulled from the channel, but never the 404.

I think the problem is that the template as set up is told to fetch an article/page from the channel - so if it isn't passed on explicitly it fetches one.

    {exp:channel:entries channel="pathology_content" limit="1" require_entry="yes"}

Any thoughts? Is there a way to designate this a Pages only template - ie, only show content if it's incoming from a Pages URL, otherwise 404?

2 Answers 2

2

You're already using require_entry, so the final step is to use the no_results check.

{if no_results}
    {redirect="404"}
{/if}
1

in you control panel go to Design>Template Manager > Global Template Preferences

find 404 page and assign a 404 template. it works for me hope thats help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.