MyBB Community Forums

Full Version: Include custom templates in plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm writing a plugin in which I've something as:

function foo_install(){
...
// Put in DB the following templates
box = <some html...> {$content1t}, {$content2t}, {$content3t} <some html...>,
content1 = <some html...>,
content2 = <some html...>,
content3 = <some html...>
...
}

function foo_activate(){
<some code...>
find_replace_templatesets("index", "#".preg_quote('<body>')."#i", '<body>{$boxt}');
<some code...>
}

function foo(){
<some code...>
eval("\$boxt = \"".$templates->get("box")."\";");
eval("\$content1t = \"".$templates->get("content1")."\";");
eval("\$content2t = \"".$templates->get("content2")."\";");
eval("\$content3t = \"".$templates->get("content3")."\";");
<some code...>
}

When I visit my index, box is displayed but its content no... Templates exist in databse and in template list, and if i try to replace one of {$content...t} insted of {$boxt} in the index, the content is shown. So, where could be the matter?

EDIT:

Sorry, I failed in ordering the evals. The right order is:

eval("\$content1t = \"".$templates->get("content1")."\";");
eval("\$content2t = \"".$templates->get("content2")."\";");
eval("\$content3t = \"".$templates->get("content3")."\";");
eval("\$boxt = \"".$templates->get("box")."\";");
What hook are you using?
You might be not running a hook at proper place or using an inappropriate hook.