MyBB Community Forums

Full Version: Append Template Set
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Just be careful not to pluck out a master template.
I dont wanna start messing with the database just to append a variable to be honest. I guess its not possible any other way though.
Well, if you don't want users to be able to change where it goes (as in, it is always needed at the bottom), you could alter the template after it is added to the cache?
How would I go about doing that ?
Hook into global_end;

function plugin_globalend()
{
	global $templates;

	// Retrieve the template
	$template = $templates->get('calendar');

	if(isset($template))
	{
		// Template can be modified; modify it while in the cache
		$templates->cache['calendar'] .= "\n<div class='test-container'>Hello world</div>";
	}
}

This way, you're not physically altering any template - just the data that is held in the template cache. On load, the calendar template will have whatever you've added to the bottom (bad example but I always abuse that template in testing).
Ohhhhh, that looks promising. Thanks tomm I'll give that a go. Lol@ "I always abuse that template"
Append:
find_replace_templatesets('header', '#$#', 'Hai guys, aren\'t I not uncool?');
Prepend:
find_replace_templatesets('footer', '#^#', 'PS I liek mudkipz');
(2012-06-22, 09:55 AM)Yumi Wrote: [ -> ]Append:
find_replace_templatesets('header', '#$#', 'Hai guys, aren\'t I not uncool?');
Prepend:
find_replace_templatesets('footer', '#^#', 'PS I liek mudkipz');


Your kidding me ? I'll try that yumi, and report back. Works like a dream. Thank you tomm & yumi +1
I didn't even realize you could modify the templates in the cache like that, very cool. Storing that one somewhere in my mess of a brain.
Yea the cache modification is new to me. But gonna say, yumi's is fantastic.
Pages: 1 2