Yii2 ?: condition in layouts/main.php -
i want write condition this, example:
yii::$app->user->isguest ? ( ['label' => 'sign up', 'url' => ['/site/signup']] ):( //do nothing )
can ?:
condition without else
part?
edit:
it sent array 'items' => []
, that's why code below doesn't work:
if(yii::$app->user->isguest)( ['label' => 'sign up', 'url' => ['/site/signup']]; )
the full code:
navbar::begin([ //somecode ]); echo nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [ yii::$app->user->isguest ? ( ['label' => 'sign up', 'url' => ['/site/signup']] ):( //how nothing here??? ) ], ]);
you may write -
['label' => 'sign up', 'url' => ['/site/signup'], 'visible' => yii::$app->user->isguest ]
Comments
Post a Comment