Revision #10 has been created by Mike on May 3, 2013, 1:57:40 PM with the memo:
Add problem with CMenu and visible=>null
« previous (#9)
Changes
Title
unchanged
The Comedy of Errors
Category
unchanged
Others
Yii version
unchanged
Tags
unchanged
errors comedy
Content
changed
[...]
$total += $rel->count;
}
echo $total; // wrong result!!
```
I wasted 12 hours debugging this.
`visible` option in CMenu and `null` values
-----------------------------------------
Use a parameter `feature.enabled` to enable/disable a feature through configuration. And then wonder why you still see the menu item, even if you have no `feature.enabled` parameter at all.
```php
<?php $this->widget('zii.widgets.CMenu', array(
'items' => array(
array(
'label' => 'A new feature',
'url' => array('feature/view'),
'visible' => Yii::app()->params['feature.enabled'],
),
```
`Yii::app()->params['feature.enabled']` returns `null` if the parameter is not defined. But in this case that's different from `false` because `CMenu` uses `isset($items['visible'])` which returns `false` for `null` values.