Class yii\widgets\Breadcrumbs

所有类 | 属性 | 方法

继承yii\widgets\Breadcrumbs » yii\base\Widget » yii\base\Component » yii\base\Object
可用自版本2.0

面包屑显示一个链接列表显示当前页面的位置在整个网站的层次结构.

例如,面包屑像“家/样本/编辑”意味着用户在查看一个编辑页面的“样本文章”。他可以点击“样本文章”页面查看,或者他可以点击“家”返回主页。

使用面包屑,您需要配置美元链接属性,它指定要显示的链接。例如,

// $this is the view object currently being used
echo Breadcrumbs::widget([
    'itemTemplate' => "<li><i>{link}</i></li>\n", // template for all links
    'links' => [
        [
            'label' => 'Post Category',
            'url' => ['post-category/view', 'id' => 10],
            'template' => "<li><b>{link}</b></li>\n", // template for this link only
        ],
        ['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
        'Edit',
    ],
]);

因为面包屑通常出现在几乎每一个页面的网站,你可能会考虑将其放置在布局视图。您可以使用一个视图参数(例如$ this - > params[“面包屑”])来配置不同的视图中的链接。在布局视图中,您将这个视图参数分配给美元的链接属性如下:

// $this is the view object currently being used
echo Breadcrumbs::widget([
    'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);

公共属性

隐藏继承属性

属性类型描述定义在
$activeItemTemplatestring模板用于呈现每个活动项目在面包屑yii\widgets\Breadcrumbs
$encodeLabelsboolean是否HTML-encode链接标签。yii\widgets\Breadcrumbs
$homeLinkarray第一个链接面包屑(称为链接)。yii\widgets\Breadcrumbs
$itemTemplatestring模板用于呈现每个活动项的面包屑。yii\widgets\Breadcrumbs
$linksarray出现在面包屑链接的列表。yii\widgets\Breadcrumbs
$optionsarray面包屑的HTML属性容器标签。yii\widgets\Breadcrumbs
$tagstring面包屑容器的名称标签。yii\widgets\Breadcrumbs

公共方法

隐藏继承方法

方法描述定义在
run()呈现小部件.yii\widgets\Breadcrumbs

受保护的方法

隐藏继承方法

方法描述定义在
renderItem()呈现一个导航项。yii\widgets\Breadcrumbs

属性详情

$activeItemTemplate public property

模板用于呈现每个活动项目在面包屑。令牌} {链接将被替换为实际的HTML链接,每个活动项目.

public string $activeItemTemplate = "<li class=\"active\">{link}</li>\n"

$encodeLabels public property

是否HTML-encode链接标签。

public boolean $encodeLabels = true

$homeLink public property

第一breadcrumbs hyperlink in The home(年)链接。请公约to $连结on the format of the链接。如果this property set,it is not将default to a link to特点yii\web\Application::homeUrll:label与“家”。如果is this property false,the home链接将not be新的管理。

public array $homeLink = null

$itemTemplate public property

模板用于呈现每个活动项的面包屑。令牌} {链接将被替换为实际的HTML链接为每个活动条目。

public string $itemTemplate = "<li>{link}</li>\n"

$links public property

出现在面包屑链接的列表。如果这个属性为空,小部件不会呈现任何东西。每个数组元素代表一个的面包屑链接下面的结构:

[
    'label' => 'label of the link',  // required
    'url' => 'url of the link',      // optional, will be processed by Url::to()
    'template' => 'own template of the item', // optional, if not set $this->itemTemplate will be used
]

如果一个链接是活跃的,你只需要指定它的“标签”,而不是写美元“标签”= >标签,你可以简单地使用元标签.

自版本 2.0.1,任何额外的数组元素的每个链接将被视为超链接标记的 HTML 属性。例如,下面的链接规范将生成 CSS 类外部超链接︰

[
    'label' => 'demo',
    'url' => 'http://example.com',
    'class' => 'external',
]

从版本2.0.3每个链接可以覆盖全球美元encodeLabels参数如下:

[
    'label' => '<strong>Hello!</strong>',
    'encode' => false,
]

public array $links = []

$options public property

面包屑的HTML属性容器标签。

参见 yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.

public array $options = ['class' => 'breadcrumb']

$tag public property

面包屑容器的名称标签。

public string $tag = 'ul'

方法详情

renderItem() protected 方法

Renders a single breadcrumb item.

protected string renderItem ( $link, $template )
$linkarray

呈现的链接。它必须包含“标签”元素。“url”元素是可选的。

$templatestring

模板用于呈现链接。令牌“{like}链接”将被链接所取代。

returnstring

The rendering result

throwsyii\base\InvalidConfigException

如果$link没有“标签”元素

run() public 方法

呈现小部件。

public void run ( )

转载于:https://my.oschina.net/u/3359744/blog/861395

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值