[eluser]my9006ci[/eluser]
hi,
I want to make my own library menu
Menubar.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Menubar {
var $CI = null;
function menubars()
{
$this->CI =& get_instance();
$this->CI->load->model("menu");
$menu = $this->CI->menu->get_menu(1);
if ($menu->num_rows() > 0)
{
$menubar = '<div id="menu">';
$menubar .= '<ul class="menu">';
foreach ($menu->result() as $row)
{
$submenu = $this->CI->menu->get_submenu($row->id);
$menubar .= '<li><a >url.'" class="parent"><span>'.$row->menu.'</span></a>';
if ($submenu->num_rows() > 0)
{
$menubar .= '<ul>';
foreach ($submenu->result() as $subrow)
{
$menubar .= '<li><a >url.'"><span>'.$subrow->menu.'</span></a>';
}
$menubar .= '</ul>';
}
else
{
$menubar .= '</li>';
}
}
$menubar .= '</ul>';
$menubar .= '</div>';
}
return $menubar;
}
}
?>
then I want to put it on my controller
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->config->load('configsite');
//$this->load->library('menubar');
}
function index()
{
$data['theme'] = $this->themes('theme');
$data['menubar'] = $this->themes('menubar');
$this->load->view('head',$data);
$this->load->view('leftbar',$data);
$this->load->view('body',$data);
$this->load->view('rightbar',$data);
$this->load->view('foot');
}
function themes($tema)
{
switch($tema)
{
case 'theme':
$tema = './themes/'.$this->config->item('theme');
if (!file_exists($tema))
{
show_404();
exit;
}
else
{
return $tema.'/';
}
break;
case 'menubar':
$tema = './menuthemes/'.$this->config->item('menutheme');
if (!file_exists($tema))
{
show_404();
exit;
}
else
{
return $tema;
}
//$data['menu'] = $this->menubar->menubars();
//return $data['menu'];
break;
}
}
}
I previously checked whether the theme folder which is used in the library exists or not
Code:
case 'menubar':
$tema = './menuthemes/'.$this->config->item('menutheme');
if (!file_exists($tema))
{
show_404();
exit;
}
else
{
return $tema;
}
//$data['menu'] = $this->menubar->menubars();
//return $data['menu'];
break;
if there is a library that I show
if no error appears
how to call the library's
Please help me...