Edgar Vonk wrote: > I am just starting out looking at the siblings function. I wonder: why > doesn't it offer a way to get the siblings as a collection of nodes? Similar > to the children function? > > We find ourselves not using the siblings function at all for this reason. > Instead to get to the siblings we first get the parent of the current node > and then the parent's children. Would be nice though to simply be able to use > the siblings function.
I haven't used this function myself, but it looks like MagnoliaTemplatingUtilities.siblings() returns a SiblingsHelper object, which seems to have an iterator-like interface with methods like next() and isLast(), so I guess you could use that with a while loop to iterate over a content node's siblings. Javadoc for SiblingHelper is here: http://nexus.magnolia-cms.com/content/sites/magnolia.public.sites/ref/4.5.2/apidocs/info/magnolia/cms/util/SiblingsHelper.html You could easily add your own function that uses the siblings() method to create a collection, but using iterators is usually better for performance. There could be a lot of siblings and the returned collection could potentially use a lot of memory. Nils. ------------------------------------------------------------------------ VPRO www.vpro.nl ------------------------------------------------------------------------ ---------------------------------------------------------------- For list details, see http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
