Welcome Guest, Not a member yet? Register   Sign In
Menu Library 1.3 [05 Gen 09]
#1

[eluser]Dewos[/eluser]
I'm New, hi all.
A humble contribution for start Smile

Ver 1.3 (05/01/2009)
[*] Bugfix SEO url

Ver 1.2b (17/10/2008)[167 Downloads]
[*] Bugfix (Tnx Too Pixel)

Ver 1.2 (17/10/2008) [5 Downloads]
[+] Current Controller Check (Tnx Bob Sawyer and Jon Braud)
[*] Performance Boost (Tnx Jon Braud)
[*] Default UL list type (Tnx Too Pixel)

Ver 1.1 (15/10/2008) [37 Downloads]
[+] Direct Array Input Mode (Tnx Too Pixel)

Ver 1.0 (14/10/2008) [16 Downloads]
First Release
#2

[eluser]Référencement Google[/eluser]
Interesting contribution Dewos.

I am just not sure that setting the menu structure in a config file is the best solution, because:

- What if I want to have a multilingual menu? CI doesn't allow to use the language library in config files.
- What if I want to set a dynamic menu from a database? (CMS usage for example)

A way to solve this problem would be to accept an array when loading the library, just like does CI libraries $this->load->library('menu', $config)

You may check how this is done in existing CI libraries like Email.php or others, that will allow a coder to set his menu either from a config file, or from a dynamic source like a DB.
#3

[eluser]Daeli[/eluser]
I did this with a library reading from an xml file... Much more comfortable.
#4

[eluser]Dewos[/eluser]
Ok... it's easy... Ver 1.1 cooming soon.
#5

[eluser]Dewos[/eluser]
Ver 1.1 Done.
Just an IF added Tongue
Enjoy
#6

[eluser]Référencement Google[/eluser]
Cool, now that makes it very suitable for me to use in my projects. Thanks for a useful contribution!
#7

[eluser]Dewos[/eluser]
You're Welcome.
#8

[eluser]Bob Sawyer[/eluser]
Nice idea, I did something similar for a project not too long ago, except that mine required having a bit of code in each controller to check the current file. This seems a bit more elegant.

Problem I'm running into is that my default controller in my routes file is "home" ... so:

$config['main'] = array( anchor('/home','Home'),
anchor('/about','About Us'),
anchor('/contact','Contact Us')
);

This works great if you're actually one mysite.com/home ... but when you first go to mysite.com, you're at the root, not at "home" ... and thus the "Home" menu item is not highlighted with the "current" class.

Is this a shortcoming of your library, or is there another problem going on here?

Thanks,
Bob
#9

[eluser]Dewos[/eluser]
Redirect your main controller to Home. It's more elegant and transparent.

Code:
//.application/config/routes.php
$route['default_controller'] = "welcome";

//.application/controllers/welcome.php
class Welcome extends Controller {

        function index()
        {        
         redirect( '/home/index/', 'location');
        }
}
#10

[eluser]Bob Sawyer[/eluser]
Thanks, Dewos. Actually, the problem is that "mysite.com/" needs to redirect to "mysite.com/home" ...




Theme © iAndrew 2016 - Forum software by © MyBB