Lack of interest Abstraction of node sub-types

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.


Well-known member
I've been working on something that involves creating a new node type that has sub-types (similar to how the Forum node type has General discussion, Article, Question and Suggestion sub-types).

While not impossible to do, it involves extending classes and template modifications because the way XenForo handles the Forum sub-types, they are hard-coded one-off exceptions. Basically it's just not very clean.

It would be nice if the admin:node_add template called a method in the node handler to see if there are any sub-types and do it's magic that way rather than the template doing something special specifically with <xf:if is="$nodeType.node_type_id == 'Forum'">.

There is also one-off logic for the Forum node type in XF\Admin\Controller\Node->actionAdd() (both the $viewParams and picking up the forum_type_id upon submission).

Like what if you wanted to have new sub-type options for "Page" nodes? You would need to go add logic for that node type in templates and controller. We already have a NodeType handler... why not use it to define any sub-types (if there are any)?

I've worked around it already with template modifications and class extensions, but it doesn't "feel right" compared to how nicely abstracted most things are in XenForo.


Having the node sub-types abstracted out would (easily) allow some interesting things... maybe you want a Resource Manager node that is just XF2 addons, or maybe a Media Gallery node of a certain type.
Last edited:
Upvote 3
This suggestion has been closed. Votes are no longer accepted.
BTW, the callable() template method would make a lot more sense in templates rather than hardcoding one-off logic into templates.

<xf:if is="
    $node.node_type_id == 'Forum'
    AND $node.Data.TypeHandler
    AND $node.Data.forum_type_id != 'discussion'

Could instead be:
<xf:if is="callable($node.Data, 'getTypeHandler')">

Now we don't care what node type it is... we just care if there's a sub-type with a handler.

I think that using callable() in templates is an easy way to abstract and simplify this. 🤷🏻‍♂️
Top Bottom