XF 2.2 How can I hide Viglink code from a specific page?

PumpinIron

Well-known member
In my PAGE_CONTAINER template I have the following code right before the </body> tag:

Code:
        <xf:if is="$forum.node_id != 243">
            <script type="text/javascript">
                var vglnk = {key: 'e2eee0d0dd1241da592e3a37e126fb93'};
                (function(d, t) {
                    var s = d.createElement(t);
                        s.type = 'text/javascript';
                        s.async = true;
                        s.src = '//cdn.viglink.com/api/vglnk.js';
                    var r = d.getElementsByTagName(t)[0];
                        r.parentNode.insertBefore(s, r);
                }(document, 'script'));
            </script>
        </xf:if>

The IF statement is attempting to hide the code from this page:


Problem is, it's not working and when you view the source the code still shows up.

What am I doing wrong here? I thought that conditional statement looked correct.
 
That var may not be available in the PAGE_CONTAINER template.

Try using: <xf:if is="$__globals.forum.node_id != 243">

Otherwise dump the vars to see what it is: {{ dump(vars()) }} .

Edit: I just checked the link and that's a page node, not a forum.
Use this instead: <xf:if is="$containerKey != 'node-243'"> .
 
Last edited:
That var may not be available in the PAGE_CONTAINER template.

Try using: <xf:if is="$__globals.forum.node_id != 243">

Otherwise dump the vars to see what it is: {{ dump(vars()) }} .

Edit: I just checked the link and that's a page node, not a forum.
Use this instead: <xf:if is="$containerKey != 'node-243'"> .

That did the trick.

I was confused because while it is a page it's listed under "nodes" in the ACP so I thought my original code would work.

In any case, thanks for the help!
 
Top Bottom