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.

Using no_results for appended pagination in URL

November 03, 2009 4:07pm

Subscribe [1]
  • #1 / Nov 03, 2009 4:07pm

    Leon Dijk

    131 posts

    Hi,

    I’m trying to get my template to redirect to my 404 page whenever someone appends something like “P10” to my URL by using no_results, but I can’t seem to get it to work somehow.

    In my software/security template where I want to display a list of entries, I use this code:

    {exp:weblog:entries weblog="software" category="4" orderby="title" sort="asc" paginate="both" limit="10"}
    {paginate}....{/paginate}
    {title}
    
    {if no_results}
        {redirect="404"}
    {/if}
    {/exp:weblog:entries}

    When I visit domain.com/software/security/ for example, it will display a list of up to 10 entries, with possible pagination. This works fine. However, when there’s only 1 entry in the selected category, it shouldn’t be possible to append “P10” (or anything else) to the URL, simply because there’s only 1 entry to be displayed.

    Somehow, the no_results conditional is never called. I have tried many things, embedding the weblog entries tag etc, to no avail.

    Any ideas on what’s going wrong here?

    Many thanks in advance!
    Leon

  • #2 / Nov 04, 2009 8:55am

    Leon Dijk

    131 posts

    A simpler example:

    {exp:weblog:entries weblog="software" limit="10"}
    {title}
    {if no_results}
    no results!
    {/if}
    {/exp:weblog:entries}

    Even when there’s just 1 entry in the “software” weblog, when I append “P20” to the URL, it doesn’t show “no results!”. Instead, it just shows the title for that 1 entry, as if EE ignores the “P20” part.

    I have searched the forums, googled around for hours, tried many things, but just can’t seem to get it work properly. Am I missing something here?

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

ExpressionEngine News!

#eecms, #events, #releases