ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

404 page doesn't work with listing template

January 03, 2011 7:22pm

Subscribe [4]
  • #1 / Jan 03, 2011 7:22pm

    brianhl

    1 posts

    Using EE 1.6.8
    I created a 404 error template and it works fine except on pages that are using a listing.
    If you try http://www.hope-link.org/ghghhg, it should bring up my 404 page ok.
    If you enter http://www.hope-link.org/events/foo, it brings up a confused page that combines the events, which I’m listing on the page as a list of sections, and another totally unrelated page. Thanks for any help.

  • #2 / Jan 04, 2011 3:01pm

    Barry Cogan

    291 posts

    Hi Brianhl

    You will need to use a conditional here to check if {segment_2} is something you intended. If not then redirect it to a 404.  I have included an example below to show you what I mean.

    {!-- there should not be any segment_2 unless it is equal to category --}
    {if segment_2 AND segment_2  != "category"}
        {redirect="site/404"}
    {/if}
    
    {!-- if this is a category page, make sure the category actually exists and has entries --}
    {if segment_2 AND segment_2 == "category"}
        {exp:channel:entries channel="articles" limit="1"} 
            {categories}
                {if category_url_title != "{segment_3}"}
                    {redirect="site/404"}
                {/if}
            {/categories}
        {/exp:channel:entries}
    {/if}

    I hope this makes things a little clearer for you.

    Sincerely,

    Barry Cogan

  • #3 / Jul 29, 2011 11:00pm

    northk

    51 posts

    Thanks Barry,

    I came across this today and your code was really helpful!

    -NorthK

  • #4 / Aug 01, 2011 5:22pm

    Sue Crocker

    26054 posts

    Glad Barry was able to help. Closing older thread.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases