Details
-
Bug
-
Resolution: Unresolved
-
High
-
3.0.x-dev
-
None
Description
Trying to use a QueryType to render children of a Content items results in a "Argument 'QueryType name' is invalid: No QueryType found with that name" exception.
(Note: steps based on https://doc.ezplatform.com/en/latest/cookbook/displaying_children_of_a_content_item/#using-the-query-controller but updated to 3.0)
1. Create src/QueryType/LocationChildrenQueryType.php:
namespace App\QueryType; use eZ\Publish\API\Repository\Values\Content\LocationQuery; use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId; use eZ\Publish\Core\QueryType\QueryType; class LocationChildrenQueryType implements QueryType { public function getQuery(array $parameters = []) { return new LocationQuery([ 'filter' => new ParentLocationId($parameters['parentLocationId']), ]); } public function getSupportedParameters() { return ['parentLocationId']; } public static function getName() { return 'LocationChildren'; } }
2. Add view config in ezplatform.yaml:
folder:
controller: ez_query:locationQueryAction
template: full/folder.html.twig
match:
Identifier\ContentType: folder
params:
query:
query_type: LocationChildren
parameters:
parentLocationId: '@=location.id'
assign_results_to: items
3. Add template in templates/full/folder.html.twig:
<h1>{{ ez_content_name(content) }}</h1> {% for item in items.searchHits %} <h2><a href={{ path('ez_urlalias', {'contentId': item.valueObject.contentInfo.id}) }}>{{ ez_content_name(item.valueObject.contentInfo) }}</a></h2> {% endfor %}
4. Preview any folder on the front office.
Result: "Argument 'QueryType name' is invalid: No QueryType found with that name" exception is thrown
Attachments
Issue Links
- blocks
-
EZP-30567 As a developer I want ez_query controler to handle pagerFanta
- Closed
- links to