Welcome Guest, Not a member yet? Register   Sign In
Include a menu on every page? use url helper in a class?
#1

[eluser]haloace[/eluser]
I'm new to CI and the MVC style. What's the best way to include a menu on every page? Can I use a ci helper in a class? Basically, I tried to create a class with my menu (using the url helper) and load it in the controller on each page, but it's not working.

//controller function
function index()
{
$this->load->library('Menu');
$menu = new Menu();

$this->load->view('header',$menu);
$this->load->view('home');
$this->load->view('footer',$menu);


}

//class
class Menu {

$this->load->helper('url');
$this->$url['home'] = anchor(base_url(), 'home', array('title' => 'home'));
$this->$url['about'] = anchor('about/', 'about', array('title' => 'about'));
$this->$url['forum'] = anchor('forum/', 'forum', array('title' => 'forum'));
$this->$url['faq'] = anchor('faq/', 'faq', array('title' => 'faq'));

}


Thanks for any help.


Messages In This Thread
Include a menu on every page? use url helper in a class? - by El Forum - 10-28-2009, 09:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB