Class yii\bootstrap5\Breadcrumbs
This widget represents a Bootstrap 5 component "Breadcrumb". It displays a list of links indicating the position of the current page in the whole site hierarchy.
echo Breadcrumbs::widget([
'links' => [
[
'label' => 'the item label', // required
'url' => 'the item URL', // optional, will be processed by `Url::to()`
'template' => 'own template of the item', // optional
],
['label' => 'the label of the active item']
],
'options' => [...],
]);
or
`
php
echo Breadcrumbs::widget([
'links' => [
'the item URL' => 'the item label',
0 => 'the label of the active item',
],
'options' => [...],
]);
`
See also https://getbootstrap.com/docs/5.1/components/breadcrumb/.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$activeItemTemplate | {@inheritDoc} | yii\bootstrap5\Breadcrumbs | |
$autoIdPrefix | string | The prefix to the automatically generated widget IDs. | yii\base\Widget |
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. | yii\base\Component |
$clientEvents | array | The event handlers for the underlying Bootstrap JS plugin. | yii\bootstrap5\BootstrapWidgetTrait |
$clientOptions | array|boolean | The options for the underlying Bootstrap JS plugin. | yii\bootstrap5\BootstrapWidgetTrait |
$counter | integer | A counter used to generate $id for widgets. | yii\base\Widget |
$encodeLabels | boolean | Whether to HTML-encode the link labels. | yii\widgets\Breadcrumbs |
$homeLink | array|false | The first hyperlink in the breadcrumbs (called home link). | yii\bootstrap5\Breadcrumbs |
$id | string|null | ID of the widget. Note that the type of this property differs in getter and setter. See getId() and setId() for details. | yii\base\Widget |
$itemTemplate | {@inheritDoc} | yii\bootstrap5\Breadcrumbs | |
$links | array | List of links to appear in the breadcrumbs. | yii\widgets\Breadcrumbs |
$navOptions | array | The HTML attributes for the widgets nav container tag. | yii\bootstrap5\Breadcrumbs |
$options | array | The HTML attributes for the breadcrumb container tag. | yii\widgets\Breadcrumbs |
$stack | yii\base\Widget[] | The widgets that are currently being rendered (not ended). | yii\base\Widget |
$tag | {@inheritDoc} | yii\bootstrap5\Breadcrumbs | |
$view | yii\web\View | The view object that can be used to render views or view files. Note that the type of this property differs in getter and setter. See getView() and setView() for details. | yii\base\Widget |
$viewPath | string | The directory containing the view files for this widget. | yii\base\Widget |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of a component property. | yii\base\Component |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
__set() | Sets the value of a component property. | yii\base\Component |
__unset() | Sets a component property to be null. | yii\base\Component |
activeItemTemplate() | The template used to render each active item in the breadcrumbs. The token {link} will be replaced with the
actual HTML link for each active item. |
yii\bootstrap5\Breadcrumbs |
afterRun() | This method is invoked right after a widget is executed. | yii\base\Widget |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
beforeRun() | This method is invoked right before the widget is executed. | yii\base\Widget |
begin() | Begins a widget. | yii\base\Widget |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
encodeLabels() | Whether to HTML-encode the link labels. | yii\bootstrap5\Breadcrumbs |
end() | Ends a widget. | yii\base\Widget |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getId() | Returns the ID of the widget. | yii\base\Widget |
getView() | Returns the view object that can be used to render views or view files. | yii\base\Widget |
getViewPath() | Returns the directory containing the view files for this widget. | yii\base\Widget |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
homeLink() | The first hyperlink in the breadcrumbs (called home link). | yii\bootstrap5\Breadcrumbs |
init() | Initializes the widget. | yii\bootstrap5\BootstrapWidgetTrait |
itemTemplate() | The template used to render each inactive item in the breadcrumbs. The token {link} will be replaced with the
actual HTML link for each inactive item. |
yii\bootstrap5\Breadcrumbs |
links() | List of links to appear in the breadcrumbs. If this property is empty, the widget will not render anything. | yii\bootstrap5\Breadcrumbs |
navOptions() | The HTML attributes for the widgets nav container tag. | yii\bootstrap5\Breadcrumbs |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
options() | The HTML attributes for the widget container tag. The following special options are recognized. | yii\bootstrap5\Breadcrumbs |
render() | Renders a view. | yii\base\Widget |
renderFile() | Renders a view file. | yii\base\Widget |
run() | {@inheritDoc} | yii\bootstrap5\Breadcrumbs |
setId() | Sets the ID of the widget. | yii\base\Widget |
setView() | Sets the view object to be used by this widget. | yii\base\Widget |
tag() | The name of the breadcrumb container tag. | yii\bootstrap5\Breadcrumbs |
trigger() | Triggers an event. | yii\base\Component |
widget() | Creates a widget instance and runs it. | yii\base\Widget |
Protected Methods
Method | Description | Defined By |
---|---|---|
registerClientEvents() | Registers JS event handlers that are listed in $clientEvents. | yii\bootstrap5\BootstrapWidgetTrait |
registerPlugin() | Registers a specific Bootstrap plugin and the related events | yii\bootstrap5\BootstrapWidgetTrait |
renderItem() | Renders a single breadcrumb item. | yii\widgets\Breadcrumbs |
Events
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_RUN | yii\base\WidgetEvent | An event raised right after executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_BEFORE_RUN | yii\base\WidgetEvent | An event raised right before executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_INIT | yii\base\Event | An event that is triggered when the widget is initialized via init(). (available since version 2.0.11) | yii\base\Widget |
Property Details
The first hyperlink in the breadcrumbs (called home link). Please refer to links() on the format of the link. If this property is not set, it will default to a link pointing to yii\web\Application::$homeUrl with the label 'Home'. If this property is false, the home link will not be rendered.
The HTML attributes for the widgets nav container tag.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
Method Details
The template used to render each active item in the breadcrumbs. The token {link}
will be replaced with the
actual HTML link for each active item.
public $this activeItemTemplate ( \yii\bootstrap5\string $value ) | ||
$value | string |
Whether to HTML-encode the link labels.
public $this encodeLabels ( \yii\bootstrap5\bool $value ) | ||
$value | boolean |
The first hyperlink in the breadcrumbs (called home link).
Please refer to {@see links} on the format of the link.
If this property is not set, it will default to a link pointing with the label 'Home'. If this property is false, the home link will not be rendered.
public $this homeLink ( $value ) | ||
$value | array|false |
The template used to render each inactive item in the breadcrumbs. The token {link}
will be replaced with the
actual HTML link for each inactive item.
public $this itemTemplate ( \yii\bootstrap5\string $value ) | ||
$value | string |
List of links to appear in the breadcrumbs. If this property is empty, the widget will not render anything.
Each array element represents a single item in the breadcrumbs with the following structure.
public $this links ( array $value ) | ||
$value | array |
The HTML attributes for the widgets nav container tag.
{@see \yii\helpers\Html::renderTagAttributes()} for details on how attributes are being rendered.
public $this navOptions ( array $value ) | ||
$value | array |
The HTML attributes for the widget container tag. The following special options are recognized.
{@see \yii\helpers\Html::renderTagAttributes()} for details on how attributes are being rendered.
public $this options ( array $value ) | ||
$value | array |
{@inheritDoc}
public void run ( ) |
The name of the breadcrumb container tag.
public $this tag ( \yii\bootstrap5\string $value ) | ||
$value | string |