- Documentation >
- Search >
- Search Criteria reference >
- ParentLocationId
ParentLocationId Criterion
The ParentLocationId
Search Criterion
searches for content based on the Location ID of its parent.
Arguments
value
- int(s) representing the parent location IDs
Example
PHP
| $query->query = new Criterion\ParentLocationId([54, 58]);
|
REST API
Use case
You can use the ParentLocationId
Search Criterion to list blog posts contained in a blog:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | $query = new LocationQuery();
$query->query = new Criterion\LogicalAnd([
new Criterion\Visibility(Criterion\Visibility::VISIBLE),
new Criterion\ParentLocationId($locationId),
]);
$results = $this->searchService->findLocations($query);
$posts = [];
foreach ($results->searchHits as $searchHit) {
$posts[] = $searchHit;
}
return $this->render('full/blog.html.twig', [
'posts' => $posts,
]);
|
| <p>Posts:</p>
<ul>
{% for post in posts %}
<li>{{ post.valueObject.contentInfo.name }}</li>
{% endfor %}
</ul>
|