0
默認Yii2佈局內部條件與速記導航欄,如果條件登錄菜單項Yii2。如果陣列
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
/*
...
some items
...
*/
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link']
)
. Html::endForm()
. '</li>'
),
],
]);
如何,我可以添加幾個條目到這種狀況呢? 這不起作用(語法錯誤 - 意外「」)
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']],
['label' => 'Register', 'url' => ['/site/register']]
) :