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

[Solved]Making custom ContainerParam available in Thread_View

Discussion in 'XenForo Development Discussions' started by hqarrse, Aug 10, 2014.

  1. hqarrse

    hqarrse Active Member

    I am sure this has been covered somewhere in the forums multiple times, but I just cannot find it. Apologies if I am asking an stupid question.

    I have a small mod that checks for attachments in posts on a page and sets a variable to 1 or 0 depending on the outcome. The result is used in page_container_js_head to make a decision about advertising content.

    This is the abbreviated code:

    class Olivenet_CheckAtts_ControllerPublic_CheckAtts extends XFCP_Olivenet_CheckAtts_ControllerPublic_CheckAtts
    protected function _postDispatch($controllerResponse, $controllerName, $action)
    $controllerResponse->containerParams['hasAttachments'] = 1;
    Is there a nice simple way that I can also make the 'hasAttachments' template variable also available in the thread_view template, ideally without adding any significant backend code?

  2. hqarrse

    hqarrse Active Member

    In this case it was actually very easy once I understood what I was doing - I dip into the XF backend rarely and it's a long while since I got the mod working.

    The solution in this case was simply to add the variable to the normal params for that controller (thread in this case) rather than just adding it to the containerParams, so:

    $controllerResponse->params += array('hasAttachments' => '0');

Share This Page