Hello, it has been a long time since I lost went on these forums and a long time since I attempted at making a plugin. So I need a little assitance since I have gotten quite a bit further this time with my plugin and I need to know how I can replace text in a template.
If I want to replace something in the user profile with something else, how would I do this in the plugin automatically instead of having to make the downloader put in the template edit himself. Inspecific this is what I want to do.
In the member_profile template I want to replace the $reputation with my own $variable. How I would do this I need an example, as what I have looked at fails to do the job I want to do.
Thank you for your assistance.
Take a look at hello.php in /inc/plugins
Oh I cannot believe I forgot to look at example plugins. Thank you!
Okay so I couldn't find the line in Hello.php so I went into askimet and found this:
function akismet_activate()
{
global $db, $mybb;
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
$db->delete_query("templates", "title = 'akismet_postbit_spam'");
find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');
I don't understand this block of code looking at from the find and replace. I take it the first 'text' is a find, and second set is possibly the line your replacing, and the third set of those is what your putting in the second sets place. So if I did this would it work?
find_replace_templatesets("member", "#".preg_quote('{$warning_level}')."#i", '', 0);
find_replace_templatesets("member_profile", "#".preg_quote('{$warning_level}')."#i", '('{$my_variable}')', 0);
I have a feeling I am missing something. :/
I have waited quite a bit of time, anyone that can help me here?
the first is the template set, the preg_quote contains the regex match, the third parameter is the replacement.
So would this be correct then?
find_replace_templatesets("member", "#".preg_quote('{$warning_level}')."#i", '', 0);
find_replace_templatesets("member_profile", "#".preg_quote('{$warning_level}')."#i", '('{$my_variable}')', 0);