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.

Category reserved word and 404 template issue

October 06, 2010 3:01pm

Subscribe [5]
  • #1 / Oct 06, 2010 3:01pm

    Sophie Dennis

    31 posts

    I am hitting the same issue described in this post http://ellislab.com/forums/viewthread/161860/ except in my case I am not (currently) removing index.php or doing anything else fancy with .htaccess.

    I have set a category reserved word (the highly original “category”), and then set up the default template (blog/index) to handle both the site homepage and category pages. This was working fine until I specified a 404 page in global template preferences.

    Now, instead of using the index template to display my category pages (e.g. at http://mysite.com/index.php/category), EE is returning my 404 page. I assume it is not recognising the category reserved word as a valid segment_1? I am happy to set up a separate template to handle categories, but am not sure how this would be done.

    I link to categories using:

    {exp:channel:categories show_empty="yes" channel="blog"}
    <a href="http://{path=SITE_INDEX}">{category_name}</a>
    {/exp:channel:categories}

    In am running Build:20100430 which I think is still the public beta.

    Here is my (simplified, but tested) index template code:

    {if segment_1 == ""} {!-- this is the homepage --}
        <h1>Homepage</h1>
    
    {if:elseif segment_1 == "category"}
        {if segment_2 == ""}{!-- this is the categories homepage --}
                <h2>Categories</h2>
    <p>            {exp:channel:categories show_empty="yes" channel="blog"}<br />
                    <li><a href="http://{path=SITE_INDEX}">{category_name} - {exp:catcount cat_id="{category_id}" status="open"} entries  »</a></li><br />
                {/exp:channel:categories}<br />
        {if:else}{!-- this is a category listing page --}<br />
                {exp:channel:category_heading channel="blog" relaxed_categories="yes"}<br />
                        </p><h2><span class="catname">{category_name}</span></h2>
    <p>                    All posts relating to <span class="catname">{category_name}</span>.<br />
                    {/exp:channel:category_heading}</p>
    
    <p>        {exp:channel:entries channel="blog|file|meeting" limit="10" paginate="bottom"}<br />
                </p><h3><a href="http://{title_permalink=post}" title="{title}">{title} {if channel == "file"}({file_type}){/if}</a></h3>
    <p>    {if extract != ""}<br />
        {extract}<br />
        {if:else}<br />
        {exp:word_limit total="50"}{body}…{/exp:word_limit}<br />
        {/if}<br />
         <a href="http://{title_permalink=post}" title="{title}">read more »</a><br />
            </div><br />
            {/exp:channel:entries}<br />
        {/if}<br />
    {if:else}<br />
        {redirect='blog/404'}<br />
    {/if}

  • #2 / Oct 07, 2010 2:45am

    John Henry Donovan

    12339 posts

    Sophie,

    Can you upgrade to the most recent build(20100810) please as there has been numerous changes and fixes since then and it would be good to start troubleshooting from from the same build we are using.

    Have you got a link to your site?

    You have a quite a few conditionals in there. Can you try for testing purposes reducing your template down tot he bare minimum and then start building it back up. So to start only add the following to your template and nothing else. Does that display for you?

    {exp:channel:category_heading channel="blog" relaxed_categories="yes"}
                        <h2><span class="catname">{category_name}</span></h2>
    <p>                    All posts relating to <span class="catname">{category_name}</span>.<br />
                    {/exp:channel:category_heading}</p>
    
    <p>        {exp:channel:entries channel="blog|file|meeting" limit="10" paginate="bottom"}<br />
                </p><h3><a href="http://{title_permalink=post}" title="{title}">{title} {if channel == "file"}({file_type}){/if}</a></h3>
    <p>    {if extract != ""}<br />
        {extract}<br />
        {if:else}<br />
        {exp:word_limit total="50"}{body}…{/exp:word_limit}<br />
        {/if}<br />
         <a href="http://{title_permalink=post}" title="{title}">read more »</a><br />
            </div><br />
            {/exp:channel:entries}

  • #3 / Oct 07, 2010 6:26am

    Sophie Dennis

    31 posts

    I will try the upgrade and get back to you.

  • #4 / Oct 07, 2010 3:24pm

    Ingmar

    29245 posts

    Very good. We’ll be here.

  • #5 / Oct 08, 2010 11:51am

    Sophie Dennis

    31 posts

    Hi John/Ingmar,

    I’ve upgraded to 2.1.0 and tried the reduced code, but am still having the same issue.

    The site is in development so is running on our internal development server, so I can’t give you a link.

    If I enter the URL http://{mylocaldevserver}/index.php/category/ I get the 404 page.

    The temporary workaround I have is to use {redirect="blog/404"} instead. However I assume this is not returning a proper http 404 on the original URL.

  • #6 / Oct 08, 2010 4:29pm

    Sue Crocker

    26054 posts

    Sophie, what I do is create a page called template_group/categories (not using the reserved word) and then put in the code I need. Example found at:

    http://eehowto.com/howto/categories

    Is that something similar to what you wanted?

  • #7 / Oct 08, 2010 8:10pm

    Sophie Dennis

    31 posts

    Thanks for the suggestion Sue. Unfortunately I need a separate listing page for each category, rather than a single page which lists the posts for all categories.

    So I want to be able to have both the pages implied by:
    http://{mylocaldevserver}/index.php/category/
    and
    http://{mylocaldevserver}/index.php/category/category_name/

    As far as I can tell - on my installation at least - category URLs simply don’t work at all when a 404 page is set.

  • #8 / Oct 09, 2010 10:49am

    Sophie Dennis

    31 posts

    I have managed to resolve this on my own.

    I gave a bit more thought to Sue’s suggestion of creating a separate template for the category pages. I thought I’d tried this before and still got the 404 when using the category reserved word in the URL. However, I was obviously doing something else wrong there, because I tried it again with some simplified category code and it works fine.

    So, category URLs DO work when a 404 page is set, but they still require a valid template name (i.e. NOT the default/index template) for the first URL segment. So

    http://mywebsite.com/index.php/{template_name}/{category_reserved_word}/ works
    http://mywebsite.com/index.php/{category_reserved_word}/ doesn’t

  • #9 / Oct 10, 2010 2:22pm

    Greg Salt

    3988 posts

    Hi Sophie,

    Thanks for the update and glad that you got this issue sorted out. Please post back if required.

    Cheers

    Greg

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

ExpressionEngine News!

#eecms, #events, #releases