Welcome Guest, Not a member yet? Register   Sign In
Where to store a common variable
#1

[eluser]ramm[/eluser]
Hi

I'm working on a simple navigation helper to place a navigation menu anywhere i need it and having the current section selected, and i need a way to define the array with the menu structure to pass it to the helper.

Where should i save that array to be available for the helper?

It will look something like this:
Code:
$items = array(
            'home' => array(
                'id'      => 'home',
                'title'     => 'Home',
                'link'   => ''
            ),
            'about' => array(
                'id'      => 'about',
                'title'     => 'About Us',
                'link'   => 'aboutus'
            ),
            'services' => array(
                'id'      => 'service',
                'title'     => 'Services',
                'link'   => 'services'
            ),
            'contact' => array(
                'id'      => 'contact',
                'title'     => 'Contact Us',
                'link'   => 'contact'
            )
        );

Then i can call the menu:
Code:
<?php echo menu('about'); ?>

Or in the controller

Code:
$data['menu'] = menu('about');

And it will show the complete menu with the 'about' li set with the 'current' class.

Any ideas?


Messages In This Thread
Where to store a common variable - by El Forum - 02-11-2011, 05:40 PM
Where to store a common variable - by El Forum - 02-12-2011, 10:23 PM
Where to store a common variable - by El Forum - 02-12-2011, 10:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB