Skip to content

Instantly share code, notes, and snippets.

@andrerom
Forked from dpobel/new_way.php
Last active December 12, 2015 09:49
Show Gist options
  • Save andrerom/4754390 to your computer and use it in GitHub Desktop.
Save andrerom/4754390 to your computer and use it in GitHub Desktop.
Updated query to reflect added ContentTypeIdentifier by @crevillo in 0cb178324a63767664dc0aed0f2ddd1ace7d1e1d in January 2013
<?php
$locationService = $this->getRepository()->getLocationService();
$searchService = $this->getRepository()->getSearchService();
$query = new \eZ\Publish\API\Repository\Values\Content\Query();
$query->criterion = new \eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAND(
array(
new \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId(
2
),
new \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId(
array( 1, 20, 21 )
)
)
);
$query->sortClauses = array(
new \eZ\Publish\API\Repository\Values\Content\Query\SortClause\LocationPriority()
);
$results = $searchService->findContent( $query );
$items = array( );
foreach ( $results->searchHits as $hit )
{
$location = $locationService->loadLocation(
$hit->valueObject->contentInfo->mainLocationId
);
$items[] = $location;
}
<?php
eZContentObject::subTreeByNodeID(
array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'folder', 'page', 'contact' ),
'SortBy' => array( array( 'priority', false ) )
),
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment