MyBB Community Forums

Full Version: Add code in the beginning of a template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all !
I know that to edit a template you use for example (i copie the one wrote in the mybb documentation) :

Quote:
find_replace_templatesets(
    "index",
    "#" . preg_quote('<body>') . "#i",
    '<body>{$myVar}'
);

But i don't know how to make my {$myVar} in the beginning of a template. For example in headerinclude template, i need to insert in the end/beginning, because this template is different for each theme and it's difficult to adapt my code.

Thank you Toungue
Use a regex to match anything, with multiline option. Insert your code before/after the match.
Hi !
I used this :
   find_replace_templatesets(
        "headerinclude",
        "#(.*)#i",
        'SOMESTUFF$1'
    );
But all the headerinclude is replaced by SOMESTUFF wrote multiple times
(2015-07-02, 07:20 PM)Destroy666 Wrote: [ -> ]with multiline option.

You need the m flag so that the dot captures newlines too. and use $0 instead of $1 to get the whole captured string