Marcel
Active member
Further to my previous question, Im still stuck.
I've added 5 custom columns to the Forum table, and extended the Forum entity to read these values
My problem comes when creating a Node Tree for a public template.
Using this, I create a tree with all viewable nodes :
I now need to trim that down based on one of the fields in the Forum entity.
I'm not sure how to access those fields as we're dealing with the node repo to create the tree, and that doesn't have access to the xf_forum table.
How do I use that nodeTree to filter out those Forums based on a custom column in the forum table?
I think I can do it one of two ways (I don't know how to do either though!)
Method One:
1. Add the custom fields to xf_forum
2. Use the nodeRepo to create a full nodeTree
4. Get a list of Forums based on the custom column
4. Using that, and the nodeTree filter out those nodes from the tree that aren't in the Forum list.
Method Two:
1. Add the custom fields to xf_node
2. Use the nodeRepo to create a full nodeTree
3. Using the nodeTree, filter out those based on the custom field.
I'm struggling with Method One, as I'm stuck on step 4.
I'm struggling with Method Two, because if I extend Admin\Controller\Node class, then I can't extend the saveTypeData() method as per the XF2 Development Guide example.
Not sure which way to turn now. Which would be the best practice way to do this, one or two?
I've added 5 custom columns to the Forum table, and extended the Forum entity to read these values
My problem comes when creating a Node Tree for a public template.
Using this, I create a tree with all viewable nodes :
PHP:
/** @var \XF\Repository\Node $nodeRepo */
$nodeRepo = \XF::repository('XF:Node');
$nodeTree = $nodeRepo->createNodeTree($nodeRepo->getFullNodeList()->filterViewable());
I now need to trim that down based on one of the fields in the Forum entity.
I'm not sure how to access those fields as we're dealing with the node repo to create the tree, and that doesn't have access to the xf_forum table.
How do I use that nodeTree to filter out those Forums based on a custom column in the forum table?
I think I can do it one of two ways (I don't know how to do either though!)
Method One:
1. Add the custom fields to xf_forum
2. Use the nodeRepo to create a full nodeTree
4. Get a list of Forums based on the custom column
4. Using that, and the nodeTree filter out those nodes from the tree that aren't in the Forum list.
Method Two:
1. Add the custom fields to xf_node
2. Use the nodeRepo to create a full nodeTree
3. Using the nodeTree, filter out those based on the custom field.
I'm struggling with Method One, as I'm stuck on step 4.
I'm struggling with Method Two, because if I extend Admin\Controller\Node class, then I can't extend the saveTypeData() method as per the XF2 Development Guide example.
Not sure which way to turn now. Which would be the best practice way to do this, one or two?