Skip to content
For AI agents: the complete documentation index is available at llms.txt; this page is also available as Markdown at index.md.

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

1
2
3
4
5
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;

$query = new Query();
$query->query = new Criterion\ParentLocationId([54, 58]);

REST API

1
2
3
4
5
<Query>
    <Filter>
        <ParentLocationIdCriterion>[81, 82]</ParentLocationIdCriterion>
    </Filter>
</Query>
1
2
3
4
5
"Query": {
    "Filter": {
        "ParentLocationIdCriterion": [69, 72]
    }
}

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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Ibexa\Bundle\Core\Controller;
use Ibexa\Contracts\Core\Repository\SearchService;
use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Symfony\Component\HttpFoundation\Response;

class NavigationController extends Controller
{
    public function __construct(
        private readonly SearchService $searchService
    ) {}

    public function blogAction(): Response
    {
        $locationId = 12345;

        $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,
        ]);
    }
}
1
2
3
4
5
6
<p>Posts:</p>
<ul>
    {% for post in posts %}
        <li>{{ post.valueObject.contentInfo.name }}</li>
    {% endfor %}
</ul>