UserList topicTree filtering

Permalink
Hi,

I cannot apply 2 topic tree filters on a user list.

UserList->filterByTopicTreeA(something)
UserList->filterByTopicTreeB(something)

They both work but separately. When I combine them I get an empty UserList. I'm stuck... would a sql custom query would save me.

Thanks !!!

chawilaclef
 
shahroq replied on at Permalink Reply
shahroq
Hi,
You can either send your selected nodes as an array or send the parent category:
//first get nodes:
//use \Concrete\Core\Tree\Node\Node as TreeNode;
$topicNode1 = TreeNode::getByID(1);
$topicNode2 = TreeNode::getByID(2);
$pageList->filterByAttribute('attribute_handle', array($topicNode1, $topicNode2));
//or send the nodeIDs directly
$pageList->filterByAttribute('attribute_handle', array(1,2));
//OR: Category
$topicCategory1 = TreeNode::getByID(1);
$pageList->filterByAttribute('attribute_handle', array($topicCategory1));
//or send the nodeIDs directly
$pageList->filterByAttribute('attribute_handle', array(1));

To find out more about filtering methods check the 'Filter a user list' sections of this cheat sheet. There is a samples for each type of atribute in that section:
https://github.com/shahroq/whale_c5_cheat_sheet#filter-a-user-list...
chawilaclef replied on at Permalink Reply
chawilaclef
Thanks Shahroq

I think you misunderstood. I don't want to filter on multiple tree nodes, but multiple trees.
I have 2 topic trees: color and size.
and created 2 user attributes color and size.

I can filter them well
userList->filterByAttribute('color', 9); //blue
userList->filterByAttribute('size', 17); //small

Both works, but separately, when I combine them I got an empty result, despite some users do have both values.

I'm stuck ! Custom SQL is a nightmare.

Thanks for your help