MyBB Community Forums

Full Version: find_replace question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm making a plugin and I need to insert a javascript into the headerinclude template.
What would be the correct find_replace function to do that?
I tried the following, but it isn't working:

		find_replace_templatesets("headerinclude", "#".preg_quote("{\$newpmmsg}")."#i", "{\$newpmmsg}\r\n{\$javascript here}");
I always do it this way:
Activate section:
	find_replace_templatesets("headerinclude", '#'.preg_quote('{$newpmmsg}').'#', '<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/SCRIPTNAME.js"></script>{$newpmmsg}');

Deactivate Section:
	find_replace_templatesets("headerinclude", '#'.preg_quote('<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/SCRIPTNAME.js"></script>').'#', '', 0);

Just make sure you include this in both functions:
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
Thanks Lex, I'll try that.