Adding my own Custom xen:tag


Active member
How can I add my own <xen:tagname> ??? I was looking at XenForo_Template_Compiler and was wondering how to override this so that I could add my own custom tags, and if needed override one? Like I need to override xen:username


Well-known member
Yes, this would be great to know. I'm trying using this:

class MyXenTag_Extend_Compiler extends XenForo_Template_Compiler
And trying to override the function _setupDefaults(), but seems to not work.


Active member
The reason why that failed, and I know i'm pretty late on response. Is because XenForo creates the "Class" XenForo_Template_Compiler

Therefore your MyXenTag_Extend_Compiler will never work.. I've pretty much had to modify the core tags and add my tag in there and be pretty much done.

Chris D

XenForo developer
Staff member
Most <xen: compiler tags usually end up calling a template helper. My solution usually is to just achieve what I want using a helper and skip the additional step of having a <xen tag.

Compiler tags are nice as you can, I believe, can use named parameters and in any order.

You can have just as many parameters in normal {xen:helper helpername} tags but they have to be in the same order as they are defined in the function signature.

For one that I did recently, this means I have this:

{xen:helper helpername, '', 'paramter', '', '', 'parameter2'}

Whereas if I could create a xen compiler tag I could do something like:

<xen:tagname paramter="value" paramter2="value" />

So, ultimately, the only difference is the compiler tag is neater and easier to use.