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.

file_exists does not work on index template

June 24, 2007 1:02pm

Subscribe [3]
  • #1 / Jun 24, 2007 1:02pm

    richlogix

    2 posts

    On my index template php functions are not working like file_exists or custom file written by me. Index template has php setting as input.
    However, same function and file_exists work on a different page with php setting as output.
    Can anyone help me?

  • #2 / Jun 24, 2007 5:53pm

    Derek Jones

    7561 posts

    Moved your post to the How To forum.  You’ll need to share the code you are using in the template so the community can help you determine the cause.  If it works on output and not input, I’m guessing that the file path is coming from a tag?

  • #3 / Jun 24, 2007 10:27pm

    richlogix

    2 posts

    Yes, this is coming from a tag. Here is the relevant code segment, that I’ve failed to work properly.
    $image_path=$main_image_dir.”{unique_id}”.”/thumb_”.”{url_title}”.”.jpg”;
    if (file_exists($image_path))
    {
    $thumb_image= $image_path_rel."{unique_id}”.”/thumb_”.”{url_title}”.”.jpg”;
    }

    Any idea how to resolve this?

  • #4 / Jun 24, 2007 10:29pm

    richlogix

    2 posts

    One more thing, $main_image_dir actually contains the full server path. So, there shouldn’t be any problem with those predefined variables.

  • #5 / Jun 25, 2007 1:05am

    Derek Jones

    7561 posts

    Well, that’s simply the difference between Input Parsing and Output Parsing.  Input parsing is parsed before ExpressionEngine tags, i.e. when you need to use PHP to provide input to a tag prior to its parsing, such as a parameter.  Output parsing is parsed after ExpressionEngine tags, i.e. when the output of a tag is needed for some PHP code.

    I take it you have a template where you feel a need to have some PHP parsed on Input, and other bits on Output?  If so, you have a few simple solutions.  The first, which I recommend most, is to convert one or the other to a plugin.  The second is to use an embedded template for the Output code, as embeds are parsed after the parent template is fully parsed.  You’ll need to pass the variables via embed tags and/or explicitly globally scope them so that the embedded template has access to the other PHP variables you are using.

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

ExpressionEngine News!

#eecms, #events, #releases