MODX Community

DynamicDropdownTV - exclude templates

I’ve created 3 dynamic dropdown TVs like shown here. Now I would like to exclude certain templates or if possible generally all resources which are not containers (or parents) themselves. How would I do that?

you can adjust the where - statement within your custom-processors

example here:

1 Like

Thanks for all the help!

I managed to create the custom processor and assign it to the TVs, but I didn’t figure out, what exactly I need to change there. After some more research, my guess is I would need to check against isfolder to see if a resource is a container?

Would someone be able to give me further hints in that direction?

@bruno17 I still couldn’t figure it out, you mind giving me another hint on this?

Unfortunately I’m still stuck here, so I’ll send this as a last reach for some hints on where or how I need to exclude the unwanted template IDs within the custom-processor. Any help is highly appreciated :pray:

1 Like

I think this thread will help

https://docs.modx.com/current/en/extending-modx/xpdo/class-reference/xpdoquery/xpdoquery.where

2 Likes

That sounds right to me.

Are you looking for something like this…?

$c->where(array(
   'parent' => '0',
   'AND:isfolder' != 1,
   'AND:id:NOT IN' => array(15,16,17,20)
));
2 Likes

Thank you guys so much! I’m very new to xPDO but already amazed how easy it actually is (if you know where to look for).

@Mr_JimWest Thank you especially! Although I think there is a little syntax error in your example. Regarding to the docs and my testing your third line should look like this:

'AND:isfolder:!=' => 1,

Also I was actually looking for all resource which ARE containers, so I used:

'AND:isfolder:=' => 1,

// referring to the docs the following should be correct, but that didn't work (?):
'AND:isfolder' => 1,

But your code was a great example to easily understand the syntax, so here is my working code for future reference:

$c->where(array(
  'parent' => '0', 
  'AND:isfolder:=' => 1,
  'AND:template:IN' => array(0,9), 
  'AND:id:!=' => '103'
));
2 Likes

Ope, sorry about that. Glad you got it! :sunglasses:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.