floor12 / breadcrumbs-microdata
Html breadcrumb with microdata generator.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:package
Requires
- php: >=7.1.0
Requires (Dev)
- phpunit/phpunit: >=7.0
This package is auto-updated.
Last update: 2024-10-27 14:18:49 UTC
README
Installation
Add this package to your project with composer.
composer require "floor12/breadcrumbs-microdata"
Usage
The breadcrumbs api is simple and clear. Here are some examples. This:
use floor12\Breadcrumbs\Breadcrumbs; $elements = [ '/first' => 'First element 1', '/first/second' => 'Second element 2', 'Current', ]; (new Breadcrumbs($elements))->getHtml();
or this:
use floor12\Breadcrumbs\Breadcrumbs; (new Breadcrumbs()) ->addElement('First element 1', '/first') ->addElement('Second element 2', '/first/second') ->addElement('Current') ->getHtml();
... will generate this html code:
<ol itemscope itemtype="http://schema.org/BreadcrumbList" class="f12-breadcrumbs" id="f12-breadcrumbs"> <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a data-pjax="0" itemprop="item" href="/first"> <span itemprop="name">First element 1</span> <meta itemprop="position" content="1"> </a> </li> <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a data-pjax="0" itemprop="item" href="/first/second"><span itemprop="name">Second element 2</span> <meta itemprop="position" content="2"> </a> </li> <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <span itemprop="name">Current</span> <meta itemprop="position" content="3"> </li> </ol>
Its also possible to set your own id and CSS class name:
use floor12\Breadcrumbs\Breadcrumbs; (new Breadcrumbs([])) ->setMainId('some-id') ->setCssClass('some-css-class') ->getHtml();
Css styles
To make default pretty styled breadcrumbs, include scss/f12-breadcrumbs.scss
or scss/f12-breadcrumbs.css
to your project styles and override what you need.
Contributing
I will be glad of any help in the development, support and bug reporting of this module.