Wordpress Bundle
  • What is Wordpress Bundle?
  • Getting started
    • Installation
    • Wordpress
    • Router
    • Cron job
    • Templates
  • Reference
    • Argument resolver
    • Controller
      • AdminAction
      • BlogController
      • FrontAction
      • WordpressAction
    • Entity
      • Block
      • Blog
      • Comment
      • File
      • Image
      • Menu
      • MenuItem
      • Post
      • Term
      • User
    • Repository
      • CommentRepository
      • PostRepository
      • TermRepository
      • UserRepository
    • Service
      • PaginationService
      • BreacrumbService
  • Guides
    • Server requirements
    • Install plugins
    • Use Multisite
    • Gutenberg
    • WP Steroids plugin
      • Image options
      • Maintenance
      • Admin pages removal
      • WYSIWYG Editor
      • Feature Support
      • Multi-site configuration
      • Constants definition
      • ACF configuration
      • Menu
      • Custom Post type
      • Advanced permalink settings
      • Custom Taxonomy
      • Templates
      • Page states
      • External table viewer
      • Roles
      • Optimisations
      • Security
      • Search
    • Twig Cookbook
    • Inject variables in all templates
    • Internationalization
    • Extending Wordpress Bundle
    • Error pages
    • Site health
  • Integrations
    • Advanced Custom Fields
      • Install ACF PRO
  • Extras
    • Migrating from 1.x to 2.0
    • Roadmap
    • Changelog
    • Alternatives
Powered by GitBook
On this page
  • Methods
  • Exemple

Was this helpful?

  1. Reference
  2. Service

BreacrumbService

Retrieve ancestors links for single page

Methods

build($args)

Property
Default

add_home

true

add_current

true

data

[]

Use data to add pages between homepage and current

Exemple

Controller

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

View

{% 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 %}
PreviousPaginationServiceNextServer requirements

Last updated 1 year ago

Was this helpful?