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.

Segment Conditional on site index

November 04, 2011 2:46pm

Subscribe [4]
  • #1 / Nov 04, 2011 2:46pm

    FortySeven Media

    130 posts

    So I’m pretty familiar with using a segment variable to show information on a page. We do it all the time, actually. So I’m confused as to why this isn’t working.

    The basic idea is that I want to use category URL’s to show lists of entries, but I don’t want the category trigger in the URL..these all need to be top level directories. Essentially I’ll build out my own top level navigation with {category_url_title} and let the index page show the proper info based on the URL.

    So in my site index page I’m trying to do something like:

    {if segment_1 != ""}
    Show category list based on URL Here
    {/if}
    
    {if segment_1 == ""}
    Show homepage
    {/if}

    But if I go to a url like http://site.com/support it gets redirected to the 404 page (I’ve turned off strict URl’s btw). It does work if I go to the url http://site.com/site/support where “site” is the template group that my site index page lives in.

    I’ve never tried segment conditionals on the site index page….is this not possible to get the conditionals to work without a template group in the URL?

  • #2 / Nov 04, 2011 3:54pm

    Rob Allen

    3105 posts

    Hi Jonathan I do this a lot and it usually works fine.

    Are you calling any channel entries tags inside each conditional, I’m wondering if EE thinks it can’t find and entry based on segment 1

  • #3 / Nov 04, 2011 4:22pm

    FortySeven Media

    130 posts

    Hey Rob,

    Actually that was all that was in the template! I think I figured out a semi-fix. I had turned off strict URL’s but hadn’t set my 404 template to none. Doing this made the site index work the way I needed. Not sure what I’ll do about 404’s, but I guess I’ll cross that bridge when I get to it 😊

    Jonathan

  • #4 / Nov 04, 2011 5:22pm

    Rob Allen

    3105 posts

    Hmm that’s a Friday afternoon anomolie 😊

    I’m just building a site that uses site/index in the same way, using two conditionals to check if segment 1 exists or not. That has strict URLs on, and the 404 template at site/404 (the 404 is a template not a conditional call). All works fine.

    At least you have a workaround, I can’t replicate it though!

  • #5 / Nov 07, 2011 8:32am

    Sue Crocker

    26054 posts

    Thanks for the assist, Rob.

    FortySeven Media - I can’t tell. Do you still require assistance?

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

ExpressionEngine News!

#eecms, #events, #releases