MyBB Community Forums

Full Version: Developing new templating variable?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanna make a variable for my template such as {myplugin['infothread']}
in PHP so I can use it in my template. I cant find a thing about this, anyone know how its done?
Tried that like so:

$plugins->add_hook("forumdisplay_thread", "activeNow");
function activeNow(){
    global $db, $mybb, $templates, $some_var, $another_var; 
        // Assign value of variable in new created global template
    $another_var = "Hello MyBB"; 
        // Evaluate created template in injected variable
    eval("\$some_var = \"".$templates->get("new_global")."\";"); 
}
 function hello_activate() {
 	global $mybb, $db;
    // Template DB entry structure array
    $new_template = array(
        "title" => "new_global",
        "template" => "<div class=\"some_cssClass\">duh</div>",
        "sid" => -1,
        "dateline" => TIME_NOW
    );
    // Save created template into database
    $db->insert_query("templates", $new_template); 
 }

Get nothing. This is what im putting in forumdisplay_thread:
{$new_global}

Is that correct? I have deactivated and reactivated the plugin still to no avail.
So does it create the new template like you wanted?

if so, where are you outputting $some_var?
<snip>
Aha! I just had the wrong name. My ignorant logic assumed that new_global would be the variable name. Thanks very much!