Assuming you are familiar with how class inheritance works, your answer is YES, PHP supports it. The django thing might be overkill, but I'll try and fill you in real quick on how to do it anyways.
Note: I'm not going into using a controller here. Obviously if the page is a blog, you are going to create a blogPage object rather than just a regular Page. ALSO, I wrote this up from scratch for you, so no guarantees on it working.. but hopefully it will give you some ideas.
<?php
class Page
{
protected $content_main; // Your main page content.
protected $content_leftbar; // Your left sidebar content.
protected $content_title; // Your content title.
protected $template; // Template data.
Function getTemplate() {
// Logic for determining the template to be used in here.
// Let's say it returns the location of a cached version of the template.
return $template_file_path;
}
Function populateContentBlocks() {
// This populates the $content_BLOCK variables with data using some default
// logic you have for determining where to grab that data from.
}
Function loadPage() {
// Populates variables.
$this->populateContentBlocks();
// Fetches template
include( $this->getTemplate() );
}
} // END class
Class blogPage extends Page {
Function getTemplate() {
// Logic for determining the template to be used in here.
// Let's say it returns the location of a cached version of the template.
// OVERRIDE THE DEFAULT TEMPLATE LOGIC OF THE PAGE WITH WHAT IS RELEVENT TO
// BLOGPAGE.
}
}
?>
Template File Example:
<html>
<head>
<title><?php echo $this->content_title; ?></title>
</head>
<body>
<div class="sidebar"><?php echo $this->content_sidebar; ?></div>
<div class="mainContent"><?php echo $this->content_main; ?></div>
</body>
</html>