-
-
Save charlycoste/4350311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My\Query extends Query | |
{ | |
$this->criterion = new Criterion\LogicalAND( | |
array( | |
new Criterion\Subtree( $root->pathString ), | |
new Criterion\ContentTypeId( $ids ), | |
new Criterion\Visibility( Criterion\Visibility::VISIBLE ) | |
) | |
); | |
$this->sortClauses = array( | |
new SortClause\LocationPriority( Query::SORT_DESC ) | |
); | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \eZ\Publish\API\Repository\Values\Content\Query; | |
$locationService = $this->getRepository()->getLocationService(); | |
$searchService = $this->getRepository()->getSearchService(); | |
$urlAliasService = $this->getRepository()->getUrlAliasService(); | |
$typeService = $this->getRepository()->getContentTypeService(); | |
$identifiers = array( 'folder', 'page', 'contact' ); | |
$ids = array(); | |
foreach ( $identifiers as $identifier ) | |
{ | |
$ids[] = $typeService->loadByIdentifier( $identifier )->id; | |
} | |
$root = $locationService->loadLocation( 2 ); | |
$results = $searchService->findContent( new My\Query ); | |
$items = array( ); | |
foreach ( $results->searchHits as $hit ) | |
{ | |
$location = $locationService->loadLocation( | |
$hit->valueObject->contentInfo->mainLocationId | |
); | |
$locationUrl = $urlAliasService->reverseLookup( $location )->path; | |
$items[$locationUrl] = $location; | |
} | |
foreach ( $items as $url => $location ) | |
{ | |
echo "url: {$url} name: {$location->contentInfo->name}\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$items = eZContentObject::subTreeByNodeID( | |
array( | |
'ClassFilterType' => 'include', | |
'ClassFilterArray' => array( 'folder', 'page', 'contact' ), | |
'SortBy' => array( array( 'priority', false ) ) | |
), | |
2 | |
); | |
foreach ( $items as $node ) | |
{ | |
echo "url: {$node->attribute( 'url_alias' )} name: {$node->attribute( 'name' )}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment