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.

I give up - What is allowed and what isn't when trying to put PHP in a template or snippet?

November 08, 2011 6:33pm

Subscribe [3]
  • #1 / Nov 08, 2011 6:33pm

    davey

    27 posts

    Hi all EE’ers and all at EE -

    I am in jam and have blown 5 hours on this so far…

    I am having to use a PHP/jQuery form framework called jFormer, it is nice, but having never tried to incorporate PHP into EE, I am blown away by the sheer pain and agony of trying to get a chunk of php to not break my template. If I put an echo statement, php renders fine, the template renders fine, anything more and it breaks…

    So… Though I realize, there are hundreds of great plugins or modules in EE to do form things very snazzily… this all begs the question:

    What chokes EE when it comes to PHP being put into a template?

    Docs state you “can put php in a template” but I see nothing about what rules to follow or what will trip up EE parsing wise?

    I have turned on php parsing on input, but I do not think that is the end of this story. I see many threads here about this same topic… Clearly, this is not best practice to jam a bunch of PHP into a template… but, to build a module wrapper around this particular solid php/jQuery plugin seems crazy…

    I just 1) want to know about what I can and can’t do with php directly in templates? and 2) what are some pointers to the better docs on this topic?

    thanks a bunch in advance,

    David

  • #2 / Nov 09, 2011 7:32am

    Sue Crocker

    26054 posts

    Hi, David.

    Unfortunately there isn’t a laundry list of what can and can’t be done using PHP in templates.

    As far as rules go - you use PHP on output anytime you’re in a looping structure such as an exp:channel:entries loop. You use PHP on input when you’re not inside of a loop. You can’t mix input and output PHP - if you need to do that, you’d have to use an embed with its own PHP settings.

    Working with PHP code is more on topic in the Development and Programming forum, would you like me to move this post there?

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

ExpressionEngine News!

#eecms, #events, #releases