Hi there,
I copied code from CMenu class reference to my webapp. The only thing I changed was to remove ‘visible’ property for last menu item (‘Login’) so it would be displayed everytime. So the code is:
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
array('label'=>'Home', 'url'=>array('site/index')),
array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
)),
array('label'=>'Login', 'url'=>array('site/login')),
),
));
What I actually see in IE and FF is posted as attachement and pasted below:
888
889
Three questions:
-
Has anyone got any idea why ‘Login’ position is not being displayed?
-
Am I missing something or doing something wrong? Is this what Yii understands as ‘multi-level’, ‘nested’ menu. I was more than sure that with using nested-feature I will see a really multi-level menu like in every desktop applicaiton and on many websites. I.e. (according to above code) only ‘Home’, ‘Products’ and ‘Login’ positions would be seen and positions ‘New Arrivals’ and ‘Most Popular’ would only be displayed when user would hover mouse pointer over ‘Products’ menu item.
-
Why do I see ‘New Arrivals’ and ‘Most Popular’ positioned like it would belong to ‘Home’ if in fact they belong to ‘Products’. The same, if I make this menu structure a bit more complicated to four-level menu:
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
array('label'=>'Home', 'url'=>array('site/index')),
array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'New Arrivals', 'url'=>array('product/new')),
array('label'=>'Most Popular', 'url'=>array('product/index')),
array('label'=>'Another', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'Level 3 One', 'url'=>array('product/new')),
array('label'=>'Level 3 Two', 'url'=>array('product/index')),
array('label'=>'Level 3 Three', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'Level 4 One', 'url'=>array('product/new')),
array('label'=>'Level 4 Two', 'url'=>array('product/index')),
)),
)),
)),
array('label'=>'Login', 'url'=>array('site/login')),
),
));
I see ‘Level 3 One’ positioned like it would belong to ‘New Arrivals’, why in fact it belongs to ‘Another’ and Level 4 One’ like belonging to ‘Level 3 One’ when it actually belongs to ‘Level 3 Three’.
Each menu item is displayed spearatelly, positioned in some hard to understand by me matter. I completely can’t see where actually generated menu structure is relevand to menu structure in code? Can someone explain me, why CMenu class does not generates menu layout in the way as (in my opinion) logic would advise. I.e. see following two attachements.
Simple menu, relevant to first example of code above:
890
Complex menu, relevant to second example of code above:
891
Finally, if what I see on my webpage (first two attachements) is not an effect of a mistake by me or some other error and if this is what it meant to be (i.e. CMenu should generate menu this way - IMHO completely unusable) can some one tell me is there any other solution or way to build a menu on website that would at least be close or similar to one seen in desktop application (third and fourth attachement) or on many, many webpages?
With kind regards,
Trejder