I am new to plugin development and PHP so excuse if this question is foolish.
I'd like to add the forum jump templates on various pages such as newthread, newreply and others - via a plugin, I figured out how to "hack" this via core edit - fairly easy, but I am not sure how to do it the proper way.
Thanks in advance!
With install you can hard wire it:
Docs:
/**
* Find and replace a string in a particular template through every template set.
*
* @param string The name of the template
* @param string The regular expression to match in the template
* @param string The replacement string
* @param int Set to 1 to automatically create templates which do not exist for that set (based off master) - Defaults to 1
* @return bolean true if updated one or more templates, false if not.
*/
find_replace_templatesets($title, $find, $replace, $autocreate=1)
How to use:
require_once MYBB_ROOT.'inc/adminfunctions_templates.php';
find_replace_templatesets('template_title', '/\{\$random_var\}/', 'Extra Stuff {$random_var}');
Or on runtime via cache's:
$templates->cache['template_title'] = str_replace('{$random_var}', 'Extra Stuff {$random_var}', $templates->cache['template_title']);
Sorry but I don't understand...
Could you show me a example? Adding the forumjump templates (forumjump_advanced,forumjump_special,forumjump_bit) to newreply.php?
You need to add the {$forumjump} variable to the newthread template and eval it hooking at newthread_end.