Difference between #9 and #10 of
The Comedy of Errors

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.
19 0
15 followers
Viewed: 19 759 times
Version: 1.1
Category: Others
Written by: fsb
Last updated by: Mike
Created on: Dec 7, 2011
Last updated: 11 years ago
Update Article

Revisions

View all history