Question

As far as I noticed seeking across the internet, there's no nice&smooth method for template inheritance in Yii, but I'm wondering if there's a nice method to at least overwrite $content in a template. Basically, I'm trying to avoid something like this:

// Let's say that I have a website with a nice layout and I created a "support" module and in its main theme I want to add a nice heading and some activity status under the $content

// modules/support/templates/main.php

$content = '<div id="someCoolHeader">lorem ipsum</div>'.$content.'<div id="supportAvailability">'.isSuportActive().'</div>';

require_once(CWebApplication::getViewPath().DIRECTORY_SEPARATOR.'main.php');

How should it get done right?

Was it helpful?

Solution

There are many ways to templating. Layouts can be customised to your needs very much. Have a look at Yii definitive guide topic. Also this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top