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 includes

July 09, 2011 9:31pm

Subscribe [1]
  • #1 / Jul 09, 2011 9:31pm

    socaprice

    217 posts

    Hi all,

    I have been given a few php files that seem to work outside EE. The files are all linked via “includes”. I am now bringing those files into EE. The original files are:
    install.php
    php-cloudsandra.php
    preferences.php
    temp_header.php

    In the install.php the first few lines of code are:

    <?PHP
    
    include('preferences.php');
    include('php-cloudsandra.php');

    In the temp_header.php the first few lines of code are:

    <?PHP
    
    include('preferences.php');
    global $promoter_id;

    When I bring this into EE, I created templates in a group called ‘promoters’, templates are:
    event_install
    event_php-cloudsandra
    event_preferences
    event_temp_header

    Is the following the proper way to do the includes?
    In the event_install the first few lines of code are:

    <?PHP
    
    include('{embeds=promoters/preferences}');
    include('{embeds=promoters/php-cloudsandra}');

    and allowed php parsed on the output.


    In the event_temp_header the first few lines of code are:

    <?PHP
    
    include('{embeds=promoters/preferences}');
    global $promoter_id;

    and allowed php parsed on the output.

    Is that the proper way to do it? Cause that is not working so I am assuming not…  😖

    Regards,
    socaprice

  • #2 / Jul 11, 2011 10:45am

    Kevin Smith

    4784 posts

    Hi socaprice,

    It’s not best practice to just bring existing PHP applications into EE templates wholesale like this since it can become difficult to manage and might actually introduce your EE installation to some security vulnerabilities. We recommend only running PHP in templates if you absolutely need to, and even then only if you really have a firm grasp on EE, PHP, and the security implications of using PHP in EE templates.

    Embedding templates inside a PHP include statement doesn’t work because in EE, embedded templates are parsed by the EE parser and the whole embedded template is output along with the rest of the template into which it was embedded. The other reason it wouldn’t work is because embeds are parsed after PHP in the EE parser.

    If you’d like to integrate a PHP application, it would probably be best to do so as a plugin or module rather than inside templates. I’d recommend taking a look at our developer documentation to get started.

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

ExpressionEngine News!

#eecms, #events, #releases