Developer's Manual  Page Layout  External Page Layout  Including PHP into layout

Including PHP into layout

Adding a PHP script to the layout allows you to implement an intelligent layout and take some pressure off the SiteSupra blocks to simplify the system and improve its performance. For an example, PHP code in the layout can change or adjust page outlook according to the content type, browser used, website area accessed, or user type being logged in. Moreover, you may have just one layout file for all page types you have in your website and avoid numerous calls to include_once function.

<table border="1">
  <tr>
    <td colspan="2">
      <!--{$block(Page Header)}-->
    </td>
  </tr>
  <tr>
    <td>
      <!--{$block(Menu)}-->
    </td>
    <td>
      <!-- if first page -->
      <?if($suDOC['id'] == 1):?>
        <table>
          <tr>
            <td colspan="2">
              <!--{$block(Latest News)}-->
            </td>
            <td colspan="2">
              <!--{$block(Site Highlights)}-->
            </td>
          </tr>
        </table>
      <?else:?>
        <!--{$block(Text)}-->
      <?endif;?>
    </td>
  </tr>
</table>

SiteSupra starts processing the layout after the database connection is created and page data is loaded. Thus, you can refer to any SiteSupra variable or API function.

Before starting using PHP in the layout make sure phpTemplate and disableCache parameters in the .htsupra file have the following values:
  'disableCache' => 4,
  'phpTemplate' => 1,

To get more information on configuring SiteSupra click here.

Please login to add comments.