Is there a getThreads NOT IN thread.node_id

Brent W

Well-known member
I am looking to exclude nodes from the getThreads method but this is the only Condition I see related to nodes. Is there not a way to do this using the getThreads method? I imagine I can work around it by getting a complete list of node ids and then removing the ones that I wish to include and then adding them to this... but that seems like overkill. Am I over looking something?

PHP:
        if (!empty($conditions['node_id']))
        {
            if (is_array($conditions['node_id']))
            {
                $sqlConditions[] = 'thread.node_id IN (' . $db->quote($conditions['node_id']) . ')';
            }
            else
            {
                $sqlConditions[] = 'thread.node_id = ' . $db->quote($conditions['node_id']);
            }
        }
 
I think your workaround is a reasonable approach to be honest.

It's also probably less effort than adding additional conditions which can sometimes be difficult to extend.

It will probably cost an additional query to fetch all nose IDs first, but that shouldn't be a big problem.
 
I think your workaround is a reasonable approach to be honest.

It's also probably less effort than adding additional conditions which can sometimes be difficult to extend.

It will probably cost an additional query to fetch all nose IDs first, but that shouldn't be a big problem.

Thanks Chris. Still navigating my way through XenForo code and wanted to make sure I wasn't overlooking something.
 
Might not be the prettiest way but it works

PHP:
            $nodeModel = $this->_getNodeModel();
            $nodes = $nodeModel->getAllNodes();
           
            $cleanNodeIds = '';
            foreach ($nodes AS $node)
            {
                $cleanNodeIds .= $node['node_id'] . ',';
            }
            $cleanNodeIds = substr($cleanNodeIds, 0 , -1);
            $cleanNodeIds = explode(',', $cleanNodeIds);
            $cleanNodeIds = array_diff($cleanNodeIds, $excludeNodes);
 
Back
Top Bottom