Skip to main content
8 events
when toggle format what by license comment
Apr 28, 2012 at 14:56 comment added Quentin Pradet Since templates/header does not know about $menuItems, but templates/menu does? That's the second bullet point of my answer.
Apr 28, 2012 at 14:40 comment added kissgyorgy I want "About us" to be the page title in the browser tab, not "about". And I cannot if I put the array in the view.
Apr 28, 2012 at 14:19 comment added Quentin Pradet Ah! Simply set $data['page'] = $page;?
Apr 28, 2012 at 14:14 vote accept kissgyorgy
Apr 28, 2012 at 14:13 comment added kissgyorgy I want the active page menu item to look different, so I mark the active menu with selected class. In my question I meant that If I put the menu elements array in the view, not the controller, I can't determine what is the actual page title, so it have to reachable from the controller to assign $data['title'] based on which page is active.
Apr 28, 2012 at 13:47 comment added Quentin Pradet $data['menuItems'] becomes $menuItems in the view. So if you want to use array_keys, simply use array_keys($menuItems, "about") to get "About us". By the way, it would make more sense for "about" to be the key, and "About us" to be the value. You could then write $menuItems["about"]. Why don't you simply use a foreach over $menuItems?
Apr 28, 2012 at 13:40 comment added kissgyorgy So if I get the menu elements from database, it should go to model, right ? How can I set page title if I put the array into the view ? list($data['title']) = array_keys($this->_menu(), $page); I cannot acces the menu items from the controller then. Or can I ?
Apr 28, 2012 at 13:33 history answered Quentin Pradet CC BY-SA 3.0