View Scripts (Page Templates)

The output generated by each view script is injected into the .main div in the layout script.

All pages from the CMS Pages module will have a corresponding $node object available to the view script.

The $node object is an instance of Application_Model_Node() and has methods such as getMetaTitle(), getMetaDescription(), getName(), getImages(), getParent() etc.

There are also some handy view helpers available to fetch pages from other parts of the  that aren't directly connected to the current $node.

Below you can see $this->node->getBody() will return the richtext (TinyMCE managed) content of the page, getImages() is used to retrieve a single image which is then passed to the $this->Image() view helper for optimisation.

<div class="content">

    <div class="text">
        <?= $this->node->getBody(); ?>
    </div><!-- .text -->
    <div class="image">
        <? $img = $this->node->getImages('Content', 1); ?>
        <? if ($img) : ?>
            <img src="<?= $this->Image($img)->setWidth(300)->setHeight(300); ?>" alt="<?= $this->escape($img->getAlt()); ?>" />
        <? endif; ?>
    </div><!-- .image -->
</div><!-- .content -->

 

The above view script would be located in /application/design/yourtheme/views/scripts/templates/

Related nodes
$nodes = $this->node->getCollection()->getRelated();