eZ Community » Forums » eZ Publish 5 Platform » Can a Criterion Search return results...
expandshrink

Can a Criterion Search return results structured as a tree?

Can a Criterion Search return results structured as a tree?

Tuesday 04 February 2014 6:13:57 pm - 1 reply

For example, the following returns all the folders in the given subtree, but $data seems to be a flat list...

        $criteriaBag = array();
        $criteriaBag[] = new Criterion\Visibility( Criterion\Visibility::VISIBLE );
        $criteriaBag[] = new Criterion\Subtree( $location->pathString );
        $criteriaBag[] = new Criterion\ContentTypeIdentifier( array( 'folder' ) );
        $criteria = new Criterion\LogicalAnd( $criteriaBag );
        // Generating query
        $query = new Query();
        $query->criterion = $criteria;
        $query->sortClauses = array(
            new SortClause\LocationPriority( Query::SORT_DESC )
        );
 
        $data = $this->getRepository()->getSearchService()->findContent( $query );        

I need $data to be a hierarchical structure, is there any native code to handle this?

I guess I could make a nested Criterion search... but that could get ugly. Or I could do some clever sorting of the $data array... but again, not pretty!

Thanks

Tuesday 04 February 2014 7:55:11 pm

Hi,

 

there is nothing for this out of the box, for next release we plan to also have a location search which will return Locations instead of Content objects. Using that it should fairly easy to make a higher level api by community which returns it in such a way. 

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from