1

I've got a template with PHP enabled and set to On Output, and any PHP at all is getting commented and printed, without being processed, in the HTML.

Template (simplified):

{embed=".header"}

{exp:stash:set name="some_value" parse_conditionals="yes" parse_tags="yes"}{if 'something' == 'somethingelse'}y{/if}{/exp:stash:set}

<div>
    <?php echo 'foo'; ?>
</div>

{embed=".footer"}

Output:

<html>
<head>
    <title>Oh the Confusion</title>
</head>
<body>

<div>
    <!--<?php echo 'foo'; ?>-->
</div>

</body>
</html>

Other templates use Stash and conditionals, many use PHP, and this is the only one that combines both Stash (parsing conditionals) and embedded PHP. Caching is not an issue here. This looks like a friendly, intentional thing since the PHP obviously isn't plainly visible to the viewer, but why is this happening?

ExpressionEngine 2.5.5 with a bajillion addons that I can list if it's helpful.

Note: I've simplified my question after figuring out how to ask it better with the help of Lisa Wess. This one seems brief and cheeky because I'll be answering it myself for posterity.

  • What is your template type, Matt? – Lisa Mar 1 '13 at 21:56
  • Sorry, not the code, though that may help - but the type. HTML? CSS? Static? I'm actually wondering if it's somehow set to the latter. :) – Lisa Mar 1 '13 at 22:07
  • I just realized I answered the wrong question. It's an EE Template, "Web Page". – Matt Stein Mar 1 '13 at 22:08
  • 1
    If you can isolate the PHP out a bit - I think getting this to the bare minimum code that works might help. Then you can add things back until it breaks and figure it out that way. With how the template is set up, you're going to have to reduce and isolate to figure this out, I think. – Lisa Mar 1 '13 at 22:09
  • What a sensible idea! When the PHP is inside {if member_group == 1} it has this problem. Removing the conditional somehow makes it okay again. Does that make any sense? (I've tried variations like {if "{member_group}" == 1} etc to no avail.) – Matt Stein Mar 1 '13 at 22:23
2

You'll need to turn your PHP into a plugin or embed it in a sub-template.

You could have saved yourself a lot of time if you'd noticed that Mark Croxton himself pointed out that Stash doesn't parse PHP.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.