MyBB Community Forums

Full Version: Add custom templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,
I have been trying to accomplish this in a few different ways over the past few days with no luck.

Here is an example of what I want to do.
Say I wanted to add a Konami Code to my website (a script that performs an action when I enter a cheat code), however I did not want to clutter the code into my headerinclude.

I created a new template with the script for my Konami Code and called it konami. The Konami template is now included under my ungrouped templates in my main style.

I went into my global.php and added in:
eval("\$konami = \"".$templates->get("konami")."\";");

I then added to my headerinclude {$konami} exactly where I would normally put the script and it would work. When I visit my website, the script is not there.

It works if I just put all of the code for the script into the headerinclude.

What am I missing?

Cranium
Where you are placing {$konami} code ? If its in "near" "global_end" hook, it would not work. Try placing it near "global_start" hook.
(2011-03-17, 04:02 AM)Yaldaram Wrote: [ -> ]Where you are placing {$konami} code ? If its in "near" "global_end" hook, it would not work. Try placing it near "global_start" hook.

I put the eval right below the headerinclude's eval. Apparently that was the section specifically designed to set those templates. I put the actual {$konami} inside the headerinclude.

I just added konami to the template list as well, which hasn't helped.

EDIT: Just tried moving the eval right below the start hook... Nothing...

*hairpull*
If you're putting {$konami} in the headerinclude template then obviously you'd need to eval $konami before the headerinclude template is eval'd, but you said you're putting it right below the headerinclude eval.
(2011-03-17, 06:52 PM)MattRogowski Wrote: [ -> ]If you're putting {$konami} in the headerinclude template then obviously you'd need to eval $konami before the headerinclude template is eval'd, but you said you're putting it right below the headerinclude eval.

Not so obvious to me, thanks for the help though. It turns out I had tried it before higher in the code but I guess it would have to be in between the template list and the headerinclude. (Oh and + rep if it means anything to you)
Did you globalize the $konami variable ? e.g global $mybb, $templates, $konami;