exs / schema-breadcrumb-bundle
This bundle generates microdata for breadcrumb.
Installs: 1 180
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 9
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ~5.5|~7.0
- symfony/framework-bundle: ~2.7|~3.0
- twig/twig: ~1.18|~2.0
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is auto-updated.
Last update: 2025-01-29 05:50:02 UTC
README
What is this bundle doing ?
This bundle generates the <script>
tag containing the json object required to define the BreadcrumbList
object as defined by schema.org
Source: http://schema.org/BreadcrumbList
Installation
Add the bundle with composer :
$ composer require exs/schema-breadcrumb-bundle
Enable the bundle in the kernel :
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new EXS\SchemaBreadcrumbBundle\EXSSchemaBreadcrumbBundle(), // ... ); }
Usage
Example :
<!DOCTYPE html> <html> <head> ... {{ getJsonBreadcrumb([ { 'name': 'Category One', 'url': 'http://www.test.tld/category-one', 'image': 'http://www.test.tld/images/category-one.png' }, { 'name': 'Subcategory Two', 'url': 'http://www.test.tld/category-one/subcategory-two' }, { 'name': 'Element Three', 'url': 'http://www.test.tld/category-one/subcategory-two/element-three' } ]) }} </head> <body> ... </body> </html>
The order of the elements in the array is used to define the order of elements in the breadcrumb.
The example above will generate the ld+json tag as :
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "item": { "@id": "http://www.test.tld/category-one", "name": "Category One", "image": "http://www.test.tld/images/category-one.png" } }, { "@type": "ListItem", "position": 2, "item": { "@id": "http://www.test.tld/category-one/subcategory-two", "name": "Subcategory Two" } }, { "@type": "ListItem", "position": 3, "item": { "@id": "http://www.test.tld/category-one/subcategory-two/element-three", "name": "Element Three" } } ] } </script>
And will be interpreted by search engines as a breadcrumb like :
Category One > Subcategory Two > Element Three