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 templates - good or bad?

July 07, 2012 2:32am

Subscribe [3]
  • #1 / Jul 07, 2012 2:32am

    jackiewales

    37 posts

    EE allows for PHP to be embedded within templates. This seems to be rather frowned upon. I don’t fully understand the issues here. Could anybody offer an explanation.

  • #2 / Jul 07, 2012 4:42am

    If you’re working on a client site, and they’ll have access to the templates, they could really break stuff/create massive security holes if php is enabled. If it’s your own site, or template access will be tightly controlled, there are things that can be done with straight php that are damn near impossible otherwise - mainly because of parse order issues.

  • #3 / Jul 07, 2012 5:04am

    jackiewales

    37 posts

    Thank you Dylan, that is just the problem I’ve run into, I could not squeeze what I wanted out existing tags.  What might be an example of a security hole? Just to make sure I avoid!

  • #4 / Jul 07, 2012 5:03pm

    “Enabling PHP in a template will enable anyone with editing rights for that template to become a de-facto Super Admin since they can execute any PHP they want in that template, including PHP that can reveal information about your system, PHP that can delete data from your database, etc. Exercise extreme caution before enabling this option if you permit others to edit your templates.”

    http://ellislab.com/expressionengine/user-guide/templates/php.html

     

  • #5 / Jul 08, 2012 4:21am

    jackiewales

    37 posts

    Brilliant fully understand that now. I have careful control over templates so it should not present an issue. Thank you for explaining.

  • #6 / Jul 18, 2012 9:53pm

    Bransin

    157 posts

    Another thing to consider is writing a quick plugin. Often I’ll start with writing PHP in a template, and then convert it to a plugin. Makes templates clean and gives you the possibility to do anything using EE syntax.

    Great starting point in creating a plugin: http://pkg.io/

  • #7 / Jul 19, 2012 4:12am

    jackiewales

    37 posts

    Thank you excellent pointer.  The mere word “plugin” has me feared.  I did not see it as a natural extension of some of the things I am already doing, will give it a go!

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

ExpressionEngine News!

#eecms, #events, #releases