Can you register a variable or helper method?

Razasharp

Well-known member
I'd like to create a helper method and have it available in views (templates) as I will use it a number of times so would prefer to DRY - the code may be added to so it would be best to be able to update it in one place.

Something like:

Code:
def my_special_forums
  <xen:if is="in_array({$forum.parent_node_id}, array(21, 22, 68, 79)">
    return true
  <xen:else />
    return false
  </xen:if>
end

So then I could use something like this in the templates:

Code:
<xen:if is={$my_special_forums}>
  do this
</xen:if>

(I am not sure if you call helper methods methods or functions, hence my pseudo ruby-xenforo code above)

If it isn't possible to do it via helpers, can I do it once at the top of a template? Though of course it would be ideal to have this defined once and available to all templates.
 
Top Bottom