Skip to content

Instantly share code, notes, and snippets.

@janit
Last active December 20, 2016 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janit/4323845afd737fafcdead846a17f7b56 to your computer and use it in GitHub Desktop.
Save janit/4323845afd737fafcdead846a17f7b56 to your computer and use it in GitHub Desktop.
<?php
/**
* @Route("/test",name="testroute")
* @Template
*/
public function testAction(Request $request, Checkout $checkout)
{
$repository = $this->get('ezpublish.api.repository');
$contentService = $repository->getContentService();
$locationService = $repository->getLocationService();
$searchService = $repository->getSearchService();
$vars = [];
$vars['random'] = rand(1,20000);
$vars['location'] = $locationService->loadLocation(55);
$vars['content1'] = $contentService->loadContent(84);
$vars['content2'] = $contentService->loadContent(1235);
$query = new LocationQuery();
$query->filter = new Criterion\LogicalAnd([
new Criterion\Subtree($vars['location']->pathString),
new Criterion\ContentTypeIdentifier( 'feature' )
]);
$results = $searchService->findLocations($query);
$vars['results'] = $results;
return $vars;
}
{{ ez_render_field(content1,'name') }} -- {{ ez_render_field(content2,'name') }}
<ul>
{% for hit in results.searchHits %}
<li><a href="{{ path(hit.valueObject) }}">{{ hit.valueObject.ContentInfo.name }}</a></li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment