Combining the Template and Module
This section will go through how the CMS puts together a webpage using the sample template and module described in the previous two sections.
Here is our standard page template:
<html>
<head>
<title><? echo $this->PAGE["cms_title"]; ?></title>
</head>
<body>
<? echo $this->PAGE["cms_content"]; ?>
<p>Last Updated: <? echo $this->PAGE["Page_Updated"]; ?></p>
</body>
</html>
<head>
<title><? echo $this->PAGE["cms_title"]; ?></title>
</head>
<body>
<? echo $this->PAGE["cms_content"]; ?>
<p>Last Updated: <? echo $this->PAGE["Page_Updated"]; ?></p>
</body>
</html>
Here is our articles module:
<? $this->PAGE["cms_title"] = $this->PAGE["Article_Title"]; ?>
<h2 class="title"><? echo $this->PAGE["Article_Title"]; ?></h2>
<p>By <span class="author"><? echo $this->PAGE["Article_Author"]; ?></span></p>
<? echo $this->PAGE["Article_Text"]; ?>
<h2 class="title"><? echo $this->PAGE["Article_Title"]; ?></h2>
<p>By <span class="author"><? echo $this->PAGE["Article_Author"]; ?></span></p>
<? echo $this->PAGE["Article_Text"]; ?>
And here is some sample page content from pages_Articles:
+------------+---------+---------------+---------------+
| Article_Id | Page_Id | Article_Title | Article_Aut...|
+------------+---------+---------------+---------------+
| 5 | 1 | How to... | John Smith ...|
+------------+---------+---------------+---------------+
First the module is parsed. It assigns
How to...
to the variable $this->PAGE["cms_title"] and
<h2 class="title">How to...</h2>
<p>By <span class="author">John Smith</span></p>
<p>Some text.</p>
<p>By <span class="author">John Smith</span></p>
<p>Some text.</p>
to $this->PAGE["cms_content"].
Next the template is parsed. Replacing all the variables in the template code we get the final result:
<html>
<head>
<title>How to...</title>
</head>
<body>
<h2 class="title">How to...</h2>
<p>By <span class="author">John Smith</span></p>
<p>Some text.</p>
<p>Last Updated: 2005-05-05 05:05:05</p>
</body>
</html>
<head>
<title>How to...</title>
</head>
<body>
<h2 class="title">How to...</h2>
<p>By <span class="author">John Smith</span></p>
<p>Some text.</p>
<p>Last Updated: 2005-05-05 05:05:05</p>
</body>
</html>
Which is sent to the browser as the final page.






















