-
- 178 Posts
Hi folks,
I wondered if there is a way to simply check whether resource has children or not.
Regards,
Mike
//Why use windows since there is a door?//
-
- 44 Posts
I would also like to find out how to do this.
I am trying to add an extra class to html based on a condition if resource has children or has a parent other than `0` and can’t figure it out yet. Kind of have a workaround with *isfolder:eq=`1` filter but its not a great solution...
please help
many thanks...
-
- 793 Posts
If a resource has children, automatically its variable [tt][[*isfolder]][/tt] gets the value 1. So if there aren’t any resources set as container despite not having children (which normally is the case) then you just need to refer to [tt][[*isfolder]][/tt].
Note:
I just found that if you put [tt][[*isfolder]][/tt] into the content of a page, then in case of a container you get the output 1 (like expected) - but if it is not a container, the output will be empty (instead of 0)!
-
- 1,624 Posts
... but if you uncheck isfolder than the output will be empty even if it has children.
Maybe a fix for the code above would be to test for unpublished documents.
-------
I think I found a bug in 2.1.0. rc3. Can some one confirm:
If you have a container with children and you un-check ’Container’, save, check ’Container’ and preview the page.
In my case I get the home page not the Container.
I think there is some sort of redirect happening.
Thanks
-
- 24,544 Posts
Quote from: cipa at May 11, 2011, 03:59 AM
... but if you uncheck isfolder than the output will be empty even if it has children.
Maybe a fix for the code above would be to test for unpublished documents.
-------
I think I found a bug in 2.1.0. rc3. Can some one confirm:
If you have a container with children and you un-check ’Container’, save, check ’Container’ and preview the page.
In my case I get the home page not the Container.
I think there is some sort of redirect happening.
Thanks
I think that’s because the version stored in the DB doesn’t match the version in memory (since you didn’t save it after checking the box). If containers have a different suffix, the URL won’t be correct, the page won’t be found, and you’ll be redirected to the error page (by default, the home page).
FYI, isfolder is automatic in Evolution if the doc has children. In Revolution, OTOH, isfolder and $resource->hasChildren() (or $modx->resource-hasChildren() for the current doc) are independent.
-
- 24,544 Posts
So it seems isFolder controls the FURL. On the default FURL settings isFolder will add .html if uncheck even if it has children.
Yes, I think that’s the case (it’s isfolder, BTW, not isFolder -- all resource fields are lowercase). I think isfolder also controls the treatment in Wayfinder and getResources.
hasChildren() just checks to see if there are children. isfolder is used because it’s much faster to just check the resource field than to do a query to find out if there are children.