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.

if my_template_group/segment_x exists, embed it, otherwise 404

October 25, 2007 1:26pm

Subscribe [2]
  • #1 / Oct 25, 2007 1:26pm

    doclalor

    1 posts

    I am hoping to parse the URL from the index.php page, and IF there is a file named ‘segment_2’ in my_template_group, I want to embed it. Otherwise, I would like to display something like a “File not found” message.

    I tried:

    {if segment_2==""}
            {embed="my_template_group/the_default_content"}
          {if:elseif segment_2} 
            {embed="my_template_group/{segment_2}"}
          {if:else}
            We don't have what you're looking for!
          {/if}

    Instead of

    {if:elseif segment_2}
    , I need a conditional that will test whether the file exists. Is there some way I can do this using php’s
    file_exists()

    and setting EE’s PHP Parsing Stage to “Input”?

  • #2 / Oct 25, 2007 2:49pm

    e-man

    1816 posts

    Problem here is that segment_2 refers to an url segment not to a file.
    You might be better off going with global variables.

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

ExpressionEngine News!

#eecms, #events, #releases