Hooking into page_container_head but narrowing down for your content/page

tenants

Well-known member
I'm using the page_container_head hook to add things to the <head></head>

I have to use the page_container_head (rather than adding to $head inside a template) since the content needs to be added to the beginning of <head></head>

The issue I am having is, if I add something to page_container_head, it's added globallly

There are no params sent though for the page_container_head hook:

Code:
<xen:hook name="page_container_head" params="{xen:array 'iwish={$iwish}, contentType={$contentType}'}>

So, when I add something to the hook:

Code:
public static function templateHook($name, &$contents, array $hookParams, XenForo_Template_Abstract $template){
    switch ($name)
        {               
           case 'page_container_head':
           $contents = '    <style type="text/css">html.hasJs #xzInvisA, html.hasJs #xzInvisB, html.hasJs #xzInvisC {visibility:hidden;}</style>
                ' .$contents;     
            break;
       }

It's then added for every page. I need to be able to select something that identifies my plugin page and then only add to the contents if we are on that page.

I couldn't find anything in $globalParams = $template->getParams();
Obliviously there is nothing in $hookParams, since no params are added to the page_container_head hook

Any suggestions?
 
Last edited:
Thank you, that works like a charm (y)

Code:
            case 'page_container_head':
                $globalParams = $template->getParams();
                if(in_array("contentTemplate", $globalParams) && $globalParams["contentTemplate"] == "xenzine_category_list")
                {
                    $contents = '    <style type="text/css">html.hasJs #xzInvisA, html.hasJs #xzInvisB, html.hasJs #xzInvisC {visibility:hidden;}</style>
                    ' .$contents;
                }      
            break;
 
Top Bottom