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.

PHP within {exp:channel:entries}

March 10, 2011 11:36am

Subscribe [3]
  • #1 / Mar 10, 2011 11:36am

    DougH

    205 posts

    This is making me crazy!

    Within a {exp:channel:entries} tag, the following code

    <?php echo "{avatar_filename}"; ?>

    outputs the avatar filename + extension as it should.

    However, the following code

    <?php echo substr("{avatar_filename}",0,strlen("{avatar_filename}")-4); ?>

    outputs “{avatar_filen”.

    I know there are other ways to get just the filename. That’s not the point. I’m just wondering why in heck the 2nd example isn’t echoing correctly???

  • #2 / Mar 10, 2011 1:18pm

    Jamie Rumbelow

    546 posts

    Hi DougH,

    Have you got PHP set to **Input** or **Output**?

  • #3 / Mar 11, 2011 5:08pm

    DougH

    205 posts

    I’ve tried it both ways, Jamie.

  • #4 / Mar 12, 2011 7:54pm

    Tom Jaeger

    497 posts

    Hi DoughH,
    If I’m reading your code correctly you want the first PHP snippet to output your EE tag?

    <?php echo "{avatar_filename}"; ?>

    and the second to output a modified value of the contents in the tag?

    <?php echo substr("{avatar_filename}",0,strlen("{avatar_filename}")-4); ?>

    If this is the case, you would have to have PHP parsing set to input to accommodate the first snippet; and have an embed for the second snippet with the PHP parsing set to output (for the embedded template).

    -Tom

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

ExpressionEngine News!

#eecms, #events, #releases