Jako / SuperBoxSelect

Advanced Listbox/Resource List template variable type in MODx Revolution
https://jako.github.io/SuperBoxSelect/
GNU General Public License v2.0
4 stars 9 forks source link

Depth with another context #24

Closed black-meridian closed 3 years ago

black-meridian commented 4 years ago

Hi,

i have a problem to list more than 1 level if I use a parent from another context.

only the first level of resources is available.

thanks !

Jako commented 4 years ago

Could you send a screenshot of the SuperBoxSelect template variable setting? Or could you post the serialized value in the input_properties column of modx_site_tmplvars of the SuperBoxSelect template variable?

black-meridian commented 4 years ago

thanks ! here 2 screenshots from the same template, from two different context

the first TV show all resources (because, the parent is from the same context)

Capture d’écran 2020-08-28 à 10 55 20

the second one, from another context, show only the first level 👍

Capture d’écran 2020-08-28 à 10 55 24

black-meridian commented 4 years ago

and here a screen from the TV config :

Capture d’écran 2020-08-28 à 11 08 58

Jako commented 4 years ago

It's a bug caused by this line: https://github.com/Jako/SuperBoxSelect/blob/master/core/components/superboxselect/processors/types/resources/getlist.class.php#L96

I am quite busy at the moment and the bug looks quite nasty and I can't fix this directly.

black-meridian commented 4 years ago

Thanks Jaco for your answer

my developer did a little hack before line 96 :

$myParent=$this->modx->getObject('modResource',$parent);
if($myParent){
    $contextKey=$myParent->get('context_key');
} 

it seems to work

Jako commented 4 years ago

It should be fixed like this.

Jako commented 4 years ago

Could you check this patch, please. Then I don't have to create that configuration on my test installation.

black-meridian commented 4 years ago

Hi Jako, sorry for the delay. Your patch doesn't fix the search

Jako commented 4 years ago

For whatever reason, $modx->resourceMap is empty during retrieving the child IDs with $modx->getChildIds. Maybe because no (web?) context is initialized at that moment. After retrieving the parent resource, this is the case (at least) for the context of the retrieved resource. So the fix of your developer is (almost right). I have wrapped it with a check.