You generally want to minimize the number of templates. One way to have page-specific content is to put the content in various chunks and put the name of the appropriate chunk for the current page in a TV, like this:
Then, you can display that chunk with something like this in the template:
The tag is replaced by the content of the chunk named in the TV.
If you set the default value of the TV to @INHERIT, its value for any page will be inherited from the nearest ancestor with the value set.
If you need truly dynamic content, you can use a snippet that generates the content (often using $modx->getChunk() to pull the content from the appropriate chunk). The snippet tag will be replaced by the return value of the snippet.
A more sophisticated version of that is to use Tpl chunks with placeholder tags in them. For a really simple-minded example, say you want to display the current time. You could create a Tpl chunk called ShowTime with this content:
<p>The current time is: [[+current_time]]</p>
Where you wanted to display that, you'd put a snippet tag:
Then create a snippet called CurrentTime with this code:
<?php
/* CurrentTime snippet */
$time = $time = strftime("%a %d %b %H:%M");
$modx->setPlaceholder('current_time', $time);
return $modx->getChunk('ShowTime');
Rather than using setPlaceholder(), you can send the placeholders in an array as a second argument to getChunk(). In that case, the snippet would look like this:
<?php
/* CurrentTime snippet */
$time = strftime("%a %d %b %H:%M");
$fields = array(
'current_time' => $time
);
return $modx->getChunk('ShowTime', $fields);
Welcome to MODX.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html