Add Variables to the View

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
Hi, in the PageContainer Template we can find
Code:
<xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>

I tried to manipulate it:
PHP:
/** $return is now the view object */
$return = parent::actionIndex();
            $return->containerParams += array('$head.rss'  => 'test');
I thought, this would be enough to get 'test' into the template but it's not working.
 
Try:
PHP:
$controllerResponse->subView->_params['head']['rss'] = 'test';

I think its _params at least. I know BB Code Manager does this for help.
 
Looks like it would work only if the template being rendered doesn't contain the xen:container tag. If it does, then the value set in the template takes precedence over any parameter set via 'container_public_params', extended controller action or even passed directly from the base controller action.
Code:
<xen:container var="$head.rss"> ... </xen:container>

I couldn't find any hook that would intercept and help us change that value after the child template is rendered (which overwrites our param value) and before the container is rendered.
 
Shadab's initial line is right, but down to an annoyance of array_merge (and the design of array_merge_recursive), this wasn't possible. I just put together a quick recursive merging function that will allow this to work in the next release.
 
OK, but i'm not sure if it's necessery because it's working now with the template hooks:)
 
Top Bottom