MyBB Community Forums

Full Version: When a plugin fails to inject code into a template, it should return a message
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
e.g.

"MyPlugin failed to add the following code to template template_name in theme theme_name."

Would be nice when I need to find out exactly what code needs to be added. Maybe this isn't feasible, though.
If I'm right the plugin author could do this already if he wants. I'll take a look into the code Wink
I see the problem, find_replace_templatesets() returns true when one or more templates have been updated so it's not possible to look whether one theme has failed. Probably we can return an array with updated/not updated themes so the plugin author can create a message?
Who would use it? I can't remember seeing a plugin that checked for the true/false return value.

Failure is always a possibility with this function, as custom templates may look entirely different from the default ones. The best course of action is to document the template changes required and leave it to the board admin to actually make these changes (if it doesn't happen to work automatically).
Fair enough. If it's impossible to automate such a thing without involving the plugin authors, don't worry about it. Smile
You'd have to do something new, like add another master template layer to make it semi-reliable.

The master template stores the original official MyBB template; the plugin could modify that and store the modified result in a new (official+plugins) layer; and then the admin could use the "find updated templates" to manually apply the changes to custom/modified templates, or when reverting templates, revert them to the (official+plugins) version rather than the plain official version.

Something like that.

Hard to tell if it would really be a better solution than the current system though.
imo The best option is for developers to document any template changes well (like frost said) and for admins to be aware that template editing in MyBB is still tricky business when you consider the amount of variation that is possible.
Don't know how hard it is to implement but I fully agree it should be included. A notice like: "$replacementcode couldn't be inserted into $themename theme's $templatename template." Especially when developers agree that hardly anyone uses default theme.
I only suggested it because there are lots of plugins out there that don't include this type of documentation.
Oh I wasn't saying that it was a bad suggestion, Brad. I am just saying that when your plugin edits templates it is important to let people know what you are trying to insert into the templates so that if it fails then they can manually enter the markup.
Pages: 1 2