XF 2.0 Accessing Value from xf_forum in the Node List

jmurrayhead

Well-known member
Bear with me as I've spent over a decade with .NET and C# and this is very different than I'm used to. So far I've managed to add a column to xf_forum and manipulate the data in that column from the edit forum template. All is good there. Now I want to access that value from the node_list_forum template. What would be the most appropriate way of going about this? I imagine it would involve extending the Node entity, maybe by adding a relation to Forum? Is modifying the relations like that even possible?

Thanks
 
Hmm .. if you've added a column to xf_forum you should have also extended the structure for \XF\Entity\Forum
https://xf2demo.xenforo.com/dev-docs/lets-build-an-add-on/#extending-the-forum-entity
https://xf2demo.xenforo.com/dev-docs/lets-build-an-add-on/#modifying-the-forum-edit-form
https://xf2demo.xenforo.com/dev-docs/lets-build-an-add-on/#extending-the-forum-save-process

I'd be interesting to know how you updated the column from edit forum without modifying the structure :)

If you've done all that, you should be able to access to forum entity by using $node->getData() in macro forum
 
Last edited:
Yeap, I've done all that. Will check out $node->getData(), but where do I find the macro forum? I noticed there are macro templates from the admincp, but didn't find anything relevant.

Thanks for the assist!
 
The macro forum is the 4th macro in tempate node_list_forum :)
You're my hero today.

For anyone else that is new to this like me, I was attempting to perform conditional logic based on my addon column. It looks like this within the macro inside the template:
Code:
<xf:if is="{$node->getData().my_addon_column}">do some stuff, brotha....<xf:else />do some other stuff, main....</xf:if>
 
Top Bottom