• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Add Variables to the View

R

ragtek

Guest
#1
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.
 

Jeremy

Well-known member
#4
Try:
PHP:
$controllerResponse->subView->_params['head']['rss'] = 'test';
I think its _params at least. I know BB Code Manager does this for help.
 

Shadab

Well-known member
#5
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.
 

Mike

XenForo developer
Staff member
#6
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.
 
R

ragtek

Guest
#7
OK, but i'm not sure if it's necessery because it's working now with the template hooks:)