Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

Integrating PHP applications in Plone

by cbonnet — last modified Dec 30, 2008 03:02 PM
How to use PHPParser to display content from an external PHP application inside Plone.

Here are the steps to follow:

  • Install PHParser
  • From the ZMI, add a PHParser item that references each of your existing PHP page. For instance, if one of your PHP pages is located in /myphp/index.php, your PHParser item will contain:

    <?php
    include="/myphp/index.php";
    ?>
  • In the ZMI, create a Page template for each PHP file. Each Page template will reference a PHParser item. For instance, if you have called your PHParser item mainPage:

    <html metal:use-macro="here/main_template/macros/master">
    <head>
    </head>
    <body>

    <tal:block metal:fill-slot="content" content="structure here/mainPage">
    </tal:block>
    </body>
    </html>
  • You need the keyword structure if your PHP file generates HTML. If your PHP file generates plain text, you can simply use: content="here/mainPage".


Thanks to Wei He, creator of PHParser, for his help.


    A more generic way

    If you have many php files this is very tedious. There is in fact a more generic way, using one single template for all:

    • Create the template in your portal_skins/custom folder instead, call it php_view and modify it slightly
    • Replace <tal:block metal:fill-slot="content" content="structure here/mainPage">
    • With <tal:block metal:fill-slot="content" content="structure here">
    • Then you access all your PHParser pages with myphppage/php_view

    Note that you must consider security if you take the generic approach: remember that all your PHP files in that particular folder will be accessible.



    Contribute

    Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.