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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -