GUI Electric Online-php-extract menu to config file

Source: Internet
Author: User

  1. New Storage Menu configuration file menus.php, and configure menu
    <?phpif( !defined(' BasePath '))Exit(' No Direct script access allowed ');/*Menu Configuration*/$config[' menus '] =Array();//Campus Life$config[' Menus '] [' life '] =Array(' name ' = ' School life ', ' submenu ' =Array(        ' News/official_news ' =Array(' name ' = ' ' official announcement '), ' life/game ' =Array(' name ' = ' Campus activity ', ' link ' = ' life/game '), ' life/flea ' =Array(' name ' = ' Flea session ', ' link ' = ' life/flea '), ' life/calendar ' =Array(' name ' = ' Flea session ', ' link ' = ' life/calendar '), ' life/map ' =Array(' name ' = ' Campus map ', ' link ' = ' life/map '), ' life/scenery ' =Array(' name ' = ' Campus view ', ' link ' = ' life/scenery '), ' life/schoolcard_lose ' =Array(' name ' = ' = ' A card lost ', ' link ' = ' life/schoolcard_lose '), ' life/schoolcard_found ' =Array(' name ' = = ' a cartoon found ', ' link ' = ' life/schoolcard_found '),    ));//Campus Learning$config[' Menus '] [' study '] =Array(' name ' = ' School life ', ' submenu ' =Array(        ' Study/translate ' =Array(' name ' = ' translate ', ' link ' = ' study/translate '), ' study/source ' =Array(' name ' = ' share resources ', ' link ' = ' study/source '), ' study/method ' =Array(' name ' = ' Small Talk learning ', ' link ' = ' study/method '), ' Study/cet 'Array(' name ' = ' search for level 46 results ', ' link ' = ' study/cet '),    ));//Campus Card$config[' Menus '] [' card '] =Array(' name ' = ' Campus business card ', ' link ' = ' card/index '));
  2. New Menu class, menu.php, and create a method to get the menu configuration data (seemingly a bit superfluous)/optimization method, modify to read the configuration class, encapsulate get configuration file
    <?phpif( !defined(' BasePath '))Exit(' No Direct script access allowed '); classmenu{/** * Get menu configuration*/     Public functionGet_menus ($param) {        $CI=&get_instance (); $CI->config->load (' Menus '); $menus=$CI->config->item (' Menus '); return $menus; }}
  3. The controller index.php invokes the menu class, gets the menu configuration data, assigns the value template
    /* *     * Home      *     /function  index ()        {// introduce the menu class, get the menus configuration         $this->load->library (' menu ');         $data $this->menu->get_menus ();         $this $data );    }
  4. Template Looping Output Menu
    <ulclass= "Nav navbar-nav navbar-left" > <liclass= "Active" > <a href= "/" > <iclass= "Glyphicon glyphicon-home" ></i> </a> </li> <?phpforeach($menus  as $menu):?> <?phpif( !isset($menu[' submenu ']) ):?> <li> <a href= "<?=site_url ($menu[' Link ']? > "><?=$menu[' Name ']?></a> </li> <?phpElse:?> <li> <a href= ""class= "Dropdown-toggle" data-toggle= "dropdown" aria-expanded= "false" > <?=$menu[' Name ']?> <spanclass= "Caret" ></span> </a> <ulclass= "Dropdown-menu" role= "menu" > <?phpforeach($menu[' submenu '] as $link=$submenu):?> <li> <a href= "<?=site_url ($submenu[' Link ']? > "><?=$submenu[' Name ']?></a> </li> <?phpEndforeach?> </ul> </li> <?phpendif?> <?phpEndforeach?> </ul>

The homepage menu part is not finished, sleepy. Re-configure tomorrow

GUI Electric Online-php-extract menu to config file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.