Discussion in 'XenForo Development Discussions' started by IFeelYourPain13, Jan 8, 2012.
How can I create template edits in my Add-On?
See my two posts here for examples of how you can change existing templates with an addon:
Or you can use template hooks if one is available to you. Look in the default templates for "xen:hook" tags. You can use the template_hook event to tie into that.
I doubt a template hook is available for Alerts. There wasn't in vbulletin either. I am trying to figure out how to get the template edits to be done by the add-on itself. With vbulletin it was quite simple, but not with XF. Any ideas on how to do a search for specific code and add code after it?
Id like to be able to not have everyone do template edits.
The only real way to do it at the moment is a post template listener that manipulates the DOM. You can see this in my add-ons. XenTrader should show it. Annoying and has a performance hit in theory (could add some form of caching I guess) but the only way I have found to do it. In the future I am going to have documents so people can disable the listener doing it and explain to do the edits themselves if they see any performance drops.
I don't understand why XF coders made it so complicated that it has to put a load on the servers. I mean do they expect everyone to use template edits? Because not all mods can make use of those.
Is there maybe a way where I can have my template code be within a variable?
and have php code locking it into the variable:
$soundcode = 'embed';
Separate names with a comma.