Straightforward approach to custom PHP code

14 Apr 2020 | by Derek

Start with a base template file, and simply echo the variable for the content and any other page specific part of the webpage in separate files.

In the page file (eg. 'page.html'):

<?php ob_start(); ?>
....
<?php $content = ob_get_clean(); ?>
<?php require_once("base.html"); ?>

In the base template (eg. 'base.html'):

<?= $content ?>

In the controller:

<?php require_once("page.html") ?>