rendered paste body<?php
class Menu {
var $menuItems = array() ;
var $menuTitle ;
function __construct(){
$this->menuTitle = 'Menu';
$this->menuItems['main'] = array('name' => 'main page', 'cmd' => 'main');
$this->menuItems['second'] = array('name' => 'sec page', 'cmd' => 'cmd2');
$this->menuItems['third'] = array('name' => 'third item', 'cmd' => 'another');
}
function setMenu(&$menu_config, $menu_title){
if (!$menu_config or !$menu_title) {
return 0;
}
echo "No argument !!!<br>";
$this->menuItems = $menu_config;
$this->menuTitle = $menu_title;
return 1;
}
function display(){
global $main_path;
global $smarty_path;
$smarty = new Smarty;
$smarty->template_dir = $smarty_path.'templates/';
$smarty->compile_dir = $smarty_path.'templates_c/';
$smarty->cache_dir = $smarty_path.'cache/';
$smarty->config_dir = $smarty_path.'configs/';
$smarty->assign('main_path',$main_path);
$smarty->assign('menu_title',$this->menuTitle);
$smarty->assign('items',$this->menuItems);
$smarty->display('main_menu.tpl');
}
}
?>
$main_menu = new Menu();
$s_menu = new Menu();
$menuTitle = 'My menu';
$smc['set'] = array('name' => 'Pag princ', 'cmd' => 'main');
$smc['by'] = array('name' => 'stuff 2', 'cmd' => 'cmd2');
$smc['me'] = array('name' => 'third item', 'cmd' => 'another');
$s_menu->setMenu($smc,$menuTitle);