onBreadcrumbLoaded
This event is triggered after the breadcrumb for a page has been created. It allows plugins to modify or interact with the breadcrumb before it is displayed in the frontend.
Availability
This event is available on all frontend pages except the homepage.
Data
Plugins must return a breadcrumb for this event; otherwise, the breadcrumb will not be available in the frontend.
Getter/Setter | Type | Required | Description |
---|---|---|---|
getData | array | - | A one-dimensional array of items representing the breadcrumb. |
setData | array | required | The original or modified $breadcrumb array that is used for the frontend. |
Example Data
Array
(
[0] => stdClass Object
(
[originalName] => 00-guides
[elementType] => folder
[contains] => pages
[status] => published
[fileType] => md
[order] => 00
[name] => Guides
[slug] => guides
[path] => /00-guides
[pathWithoutType] => /00-guides/index
[urlRelWoF] => /guides
[urlRel] => /typemill/guides
[urlAbs] => http://localhost/typemill/guides
[key] => 0
[keyPath] => 0
[keyPathArray] => Array
(
[0] => 0
)
[chapter] => 1
[active] =>
[activeParent] => 1
[hide] =>
[noindex] =>
)
[1] => stdClass Object
(
[originalName] => 00-standard-operating-procedure.md
[elementType] => file
[status] => published
[fileType] => md
[order] => 00
[name] => Standard Operating Procedure
[slug] => standard-operating-procedure
[path] => /00-guides/00-standard-operating-procedure.md
[pathWithoutType] => /00-guides/00-standard-operating-procedure
[key] => 0
[keyPath] => 0.0
[keyPathArray] => Array
(
[0] => 0
[1] => 0
)
[chapter] => 1.1
[urlRelWoF] => /guides/standard-operating-procedure
[urlRel] => /typemill/guides/standard-operating-procedure
[urlAbs] => http://localhost/typemill/guides/standard-operating-procedure
[active] => 1
[activeParent] =>
[hide] =>
[noindex] =>
)
)
Example Usage
<?php
namespace plugins\myplugin;
use \typemill\plugin;
class myplugin extends plugin
{
public static function getSubscribedEvents()
{
return [
'onBreadcrumbLoaded' => 'onBreadcrumbLoaded'
];
}
public function onBreadcrumbLoaded($plugindata)
{
$breadcrumb = $plugindata->getData();
// do something and return the breadcrumb
$plugindata->setData($breadcrumb);
}
}
See also
- Breadcrumb variable for theme developers.
- Item variable for theme developers.