1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding my own Custom xen:tag

Discussion in 'XenForo Development Discussions' started by Uniphix, Oct 11, 2011.

  1. Uniphix

    Uniphix 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
    Hugilore111 and Fuhrmann like this.
  2. Fuhrmann

    Fuhrmann 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.
    Hugilore111 likes this.
  3. Despair

    Despair Active Member

    In the exact same boat. :p
    Fuhrmann likes this.
  4. Uniphix

    Uniphix 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.
    Hugilore111 and Fuhrmann like this.
  5. Chris D

    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.
  6. Hugilore111

    Hugilore111 Member

    something has changed?
  7. Chris D

    Chris D XenForo Developer Staff Member

    No. Template helpers are still the recommended solution.
  8. Hugilore111

    Hugilore111 Member

    A few examples can be?
  9. Chris D

    Chris D XenForo Developer Staff Member

Share This Page