我正在寻找yii2码链代码
我在树枝上有布局页面想在那里添加痕迹,并希望根据页面更新它
仪表板/员工/添加员工
仪表板/员工/编辑员工
仪表板和员工将是可点击的
我在互联网上获得的关于yii2面包屑的信息非常少。
答案 0 :(得分:36)
在您的主要布局中使用:
<?=
Breadcrumbs::widget([
'homeLink' => [
'label' => Yii::t('yii', 'Dashboard'),
'url' => Yii::$app->homeUrl,
],
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
])
?>
在你看来:
$this->title = 'Add Employee';
$this->params['breadcrumbs'][] = ['label' => 'Employees', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
这将生成以下面包屑:
Dashboard / Employees / Add Employee
答案 1 :(得分:2)
在你的布局中 -
//use yii\widgets\Breadcrumbs;
<?=
Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
])
?>
在您看来 -
$this->title = 'Example';
$this->params['breadcrumbs'][] = $this->title;
希望它能奏效。
答案 2 :(得分:0)
我的代码如下所示:
DECLARE @code int
SET @code=6162
DECLARE @count1 int
SET @count1=(SELECT COUNT(*) FROM [MsumCOOP].[dbo].[DL_TRN] WHERE [M_CODE]=@code)
DECLARE @count2 int
SET @count2=(SELECT COUNT(*) FROM [MsumCOOP].[dbo].[FL_TRN] WHERE [M_CODE]=@code)
SELECT m.[CODE],m.[NAME],d.[OP_AMT]
FROM [MsumCOOP].[dbo].[MEMBER] m
FULL OUTER JOIN
(
SELECT [M_CODE] FROM [MsumCOOP].[dbo].[DL_TRN] WHERE [LOAN_COMP] IS NULL AND @count1>0
UNION ALL
SELECT [M_CODE] FROM [MsumCOOP].[dbo].[D_Loan] WHERE [LOAN_COMP] IS NULL AND @count1=0
) d
ON m.[CODE]=d.[M_CODE]
FULL OUTER JOIN
(
SELECT [M_CODE] FROM [MsumCOOP].[dbo].[FL_TRN] WHERE [LOAN_COMP] IS NULL AND @count2>0
UNION ALL
SELECT [M_CODE] FROM [MsumCOOP].[dbo].[F_Loan] WHERE [LOAN_COMP] IS NULL AND @count2=0
) f
ON m.[CODE]=f.[M_CODE]
WHERE m.code=@code
在任何视图页面上我都添加了一个代码段
<section class="content-header">
<ol class="breadcrumb">
<?php
echo Breadcrumbs::widget([
'itemTemplate' => "<li><i>{link}</i></li>\n",
'homeLink' => [
'label' => Yii::t('yii', 'Dashboard'),
'url' => Yii::$app->homeUrl,
],
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);
?>
</ol>
</section>
以上是一个简单的例子。这个问题是它没有真正给出导航的树结构。我将不得不编写一个辅助函数来跟踪每个视图页面的历史或树路径。