MyBB Community Forums

Full Version: find_replace_templatesets have problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use find_replace_templatesets in my plugins but it seems that it dont do properly
It add a template that is not same as other templates.. have not version and just have adifferentes...
Is it a bug or what?
Can you provide me with the exact code you're using?
function imeiSex_activate()
{
require MYBB_ROOT.'inc/adminfunctions_templates.php';
var_dump(
find_replace_templatesets("postbit_reputation", '/0*$/', '0')
);
}

It should delet all 0's at end of template and replace them with just one 0.
but it apears two zeroes. and strange record in db: two records with same title name and different values for template. one of them modified template and one of them just defferents!!!
In regards to it creating two templates this would be because MyBB stores master templates in the database too (with a sid of -1). Whenever you run this function and it finds an unmodified template it copies it and saves the changes to the local template set (as is what happens when you edit a template for the first time).

The result can be you have two or more templates with the same name but from different template sets.

In regards to your regular expression, * will match the '0' 0 or more times. Have you tried it as 0+ which matches one or more of the 0s?
I didn't mean master templates. I didn't count it , whit master, it reminds 3 one of themBig Grin
and about reg exp. I know * and + differents. sinc you didn't placed a "?" after * or + it dont threat as none greedy . so '/0*/ means 0 or more zeroes if there are! so it counts all of 0's at end of templates.not just one or 0 ..
reg exp have not problem IMO but problem is in two additionall templates . many other regexps didnt work . I also tried + !
Does any other faced this problem?! my plugin programming stopped because I could not modify a theme.
I've used find_replace_templateset() just fine in my programming
When I use it two times, it inserts two additionall records in DB.