PHP Class macgyer\yii2materializecss\widgets\Breadcrumbs
For example, breadcrumbs like "Home / Sample Post / Edit" means the user is viewing an edit page
for the "Sample Post". He can click on "Sample Post" to view that page, or he can click on "Home"
to return to the homepage.
To use Breadcrumbs, you need to configure its
$links property (inherited from
yii\widgets\Breadcrumbs) , which specifies the links to be
displayed.
For example,
php
$this is the view object currently being used
echo Breadcrumbs::widget([
'itemTemplate' => "{link}\n", // template for all links
'links' => [
[
'label' => 'Post Category',
'url' => ['post-category/view', 'id' => 10],
'template' => "{link}\n", // template for this link only
],
['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
'Edit',
],
]);
Because breadcrumbs usually appear in nearly every page of a website, you may consider placing it in a layout view.
You can use a view parameter (e.g.
$this->params['breadcrumbs']) to configure the links in different
views. In the layout view, you assign this view parameter to the
$links property like the following:
php
$this is the view object currently being used
echo Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);
Exibir arquivo
Open project: macgyer/yii2-materializecss
Class Usage Examples
Public Properties
Property |
Type |
Description |
|
$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. |
|
$containerOptions |
|
the HTML options for the surrounding "nav" tag. |
|
$innerContainerOptions |
|
the HTML options for the inner container tag.
Set this to 'false' if you do not want the inner container to be rendered.
The following special options are recognized:
- tag: string, defaults to "div", the name of the inner container tag. |
|
$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. |
|
$options |
|
the HTML options for the wrapper tag. |
|
$tag |
|
the name of the wrapper tag for the breadcrumbs list.
defaults to "div" |
|
Public Methods
Method |
Description |
|
init ( ) |
Initializes the widget. |
|
run ( ) : string |
Renders the widget. |
|
Protected Methods
Method Details
prepareLinks()
protected method
Generates all breadcrumb links and sets active states.
renderItem()
protected method
Renders a single breadcrumb item.
protected renderItem ( array $link, string $template ) : string |
$link |
array |
the link to be rendered. It must contain the "label" element. The "url" element is optional. |
$template |
string |
the template to be used to rendered the link. The token "{link}" will be replaced by the link. |
return |
string |
the rendering result |
public run ( ) : string |
return |
string |
the result of widget execution to be outputted. |
Property Details
$activeItemTemplate public_oe property
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 $activeItemTemplate |
$containerOptions public_oe property
the HTML options for the surrounding "nav" tag.
$innerContainerOptions public_oe property
the HTML options for the inner container tag.
Set this to 'false' if you do not want the inner container to be rendered.
The following special options are recognized:
- tag: string, defaults to "div", the name of the inner container tag.
public $innerContainerOptions |
$itemTemplate public_oe property
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.
$options public_oe property
the HTML options for the wrapper tag.
the name of the wrapper tag for the breadcrumbs list.
defaults to "div"