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

Discussion in 'XenForo Development Discussions' started by ragtek, Nov 25, 2010.

  1. ragtek

    ragtek Guest

    Hi, in the PageContainer Template we can find
    <xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>
    I tried to manipulate it:
    /** $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.
  2. Shadab

    Shadab Well-Known Member

    This should work:
    $controllerResponse->containerParams['head']['rss'] = 'Test';
  3. ragtek

    ragtek Guest

    thx, but it's not working:(
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    $controllerResponse->subView->_params['head']['rss'] = 'test';
    I think its _params at least. I know BB Code Manager does this for help.
  5. Shadab

    Shadab Well-Known Member

    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.
    <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.
  6. Mike

    Mike XenForo Developer Staff Member

    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.
    Shadab and Darkimmortal like this.
  7. ragtek

    ragtek Guest

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

Share This Page