MyBB Community Forums

Full Version: Got an error with the following
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to put up a feature to popup a message which should be removed automatically in 20 seconds.

I want to place this in the header.

So here is what I tried.

I putted this in the header:
{$popup}

And then I made a Global Template called "popup" which I put this content inside:
<link href='css/google-traffic-pop.2.css' rel='stylesheet' type='text/css'/>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script>
<script src='jscripts/gtp.min.2.js' type='text/javascript'></script>
<script language='javascript'> 

    jQuery(document).ready(function() {        

        jQuery().googleTrafficPop({
            'timeout':         0, 
            'title':         "<b>Terms of Service</b>",
            'message':         "To be able to use our website you must accept our Terms of Service.<br /><iframe src='tos.txt' width='400px' height='150px' style='color: black; background-color: #EBF2FC; border: 1px solid #3C0006;'><p><a href='misc.php?page=tos' background=''>Please see our Terms of Service.</a></p></iframe><br />Please note that you will get this notice whenever we have a new update in our Terms of Service.",
            'url':             "http://www.gamerstick.com",
            'wait':            0,
            'opacity':        45,
            'advancedClose':false,
            'closeable':    false
        });

    });

</script>

<link type='text/css' rel='stylesheet' href='css/334858902-widget_css_2_lightbox_bundle.2.css' />

But when this is done I do not get any popup at all.

Any idea?

NOTE: It works for my custom pages? But not when I try put it into a template.
How are you calling the template?
(2011-11-08, 01:03 PM)Malcolm. Wrote: [ -> ]How are you calling the template?

With this code in the header template:
{$popup}
That's not going to do anything.

You need to hook the function to global_start and eval the template to the variable $popup first.
(2011-11-08, 01:23 PM)Malcolm. Wrote: [ -> ]That's not going to do anything.

You need to hook the function to global_start and eval the template to the variable $popup first.

How can I do this?
I believe hooks can be only added through plugins.

$plugins->add_hook("global_start", "my_function");

function my_function() {
    global $templates, $popup;

    eval("\$popup = \"".$templates->get("popup")."\";");

}

(2011-11-08, 01:28 PM)Malcolm. Wrote: [ -> ]

$plugins->add_hook("global_start", "my_function");

function my_function() {
    global $templates, $popup;

    eval("\$popup = \"".$templates->get("popup")."\";");

}


Okay. Thanks a lot.
I will try this.

But what if I later want to remove this again? Does this automatically get done by uninstalling the plugin?