Add code in the beginning of a template
#1
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
[Image: Prez.png]
Reply
#2
Use a regex to match anything, with multiline option. Insert your code before/after the match.
Reply
#3
Hi !
I used this :
   find_replace_templatesets(
        "headerinclude",
        "#(.*)#i",
        'SOMESTUFF$1'
    );
But all the headerinclude is replaced by SOMESTUFF wrote multiple times
[Image: Prez.png]
Reply
#4
(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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)