---
description: Retrieve ancestors links for single page
---

# BreacrumbService

## Methods

#### build($args)

| Property     | Default |
| ------------ | ------- |
| add\_home    | `true`  |
| add\_current | `true`  |
| data         | `[]`    |

{% hint style="info" %}
Use `data` to add pages between homepage and current
{% endhint %}

## Exemple

Controller

```php
public function articleThematicAction(array $posts, PostRepository $postRepository, BreadcrumbService $breadcrumbService)
{
  $context = ['posts'=>$posts];
  $context['breadcrumb'] = $breadcrumbService->build();
  
  return $this->render('page/term.twig', $context);
}
```

View

```liquid
{% set breadcrumb = breadcrumb|default(blog.breadcrumb) %}
{% if breadcrumb %}
<ul>
  {% for page in breadcrumb %}
    <li>
      {% if not loop.last %}
        <a href="{{ page.link }}">{{ page.title }}</a>
      {% else %}
        {{ page.title }}
      {% endif %}
    </li>
  {% endfor %}
</ul>
{% endif %}
```
