Here’s what I was thinking…I wrote a class to over ride Colin’s class while he decides if this is something he would like to pursue. Here is a replacement for add_region():
/**
* Dynamically add region to the currently set template
*
* @access public
* @param string Name to identify the region
* @param array Optional array with region defaults
* @param string Optional string region name to deposit this new region before in stack
* @return void
*/
function add_region($name, $props = array(), $before = null)
{
if ( ! is_array($props))
{
$props = array();
}
if ( ! isset($this->regions[$name]))
{
if ( $before === null)
{
$this->regions[$name] = $props;
}
else
{
$pos = array_search($before,array_keys($this->regions));
$this->regions = array_merge(array_slice($this->regions,0,$pos), array( $name => $props ), array_slice($this->regions,$pos));
}
}
else
{
show_error('The "'. $name .'" region has already been defined.');
}
}
Now with this, you can dynamically add regions just like Colin has provided. But with the additional parameter you can place the regions in the array stack relevant to where it shows up on the page. (it could be argued that with CSS this is a moot point.)
So now you could add widgets to your left panel, right panel, footer, header, banner, change you content region into a paneled region etc. This becomes relevant when thinking about user roles and access rights. Logically, you now can dynamically add and remove regions based upon the access rights of the person logged in.
You get the idea.
To implement this, the call would look like this:
$this->template->add_region('myNewRegion','','footer');
This would add a new region in output page (in the regions stack) above the footer.
Hope the explains what I meant.
Randy