Welcome Guest, Not a member yet? Register   Sign In
Need to integrate navigation
#1

[eluser]makkal[/eluser]
Hi everybody,

I am working in a web application development. In that i want to keep my navigation as a dynamic one. It should 3 level navigation menu by showing the active page.

Please give your suggestions on how to manage this. Is that i need to write any common functions in helper or plugins and calling it in the controller. Or some kind of function directly calling in view.

Kindly let me know your ideas. Thank you.

-Mak
#2

[eluser]mlage[/eluser]
Check out the Template Parser class (not automatically loaded)

http://ellislab.com/codeigniter/user-gui...arser.html

It allows for dynamic creation of menus from a view.

That or you will have to write the php code to take your data that represents the menu, and through some kind of loop, make a string of the data and load it. You can load strings of data, like a view, like this:
Code:
$string = $this->output->get_output(); //Gets currently loaded views
$string .= $navigationCode; //$navigationCode should be the variable holding the HTML code of your dynamic navigation
$string = $this->output->set_output(); //Updates the output

I'll be watching this thread... so if you need help, just post back
#3

[eluser]makkal[/eluser]
Hi mlage,

Thanks for your reply.
I am seeing the template parser used for the navigation.
But is it possible to keep this code as general function to be called in all pages.

Now it seems that we need to repeat this navigation code in each page.

Please advise me on this. Thank you.

-Mak
#4

[eluser]mlage[/eluser]
The keywords of your statement that hurt my eyes to read... "we need to repeat this navigation code in each page"

Programming is beautiful in that one of its purposes is to prevent repeating code. So to answer your question, yes you can keep it as a general function. There are many ways on doing this...

I would look into writing a short library that has one class with the functions you want... then you load that library for whatever controller needs it and call the appropriate functions.

Check out this:
http://ellislab.com/codeigniter/user-gui...aries.html

Any other questions, just post back here
#5

[eluser]umefarooq[/eluser]
as mlage say there are many ways you can do this, if you don't want to use library then you can use base controller put you navigation code in base controller like MY_Controller extend you controller with MY_Controller and call navigation code in your views,

check base controller how they work

http://www.philsturgeon.co.uk/news/2010/...ing-it-DRY

2nd check widget there are two type widget available in ignited code section one with CI loader and on as plug in which one you like its up to you both will work great

with CI loader
http://ellislab.com/forums/viewthread/161374/

plugin
http://ellislab.com/forums/viewthread/109584/




Theme © iAndrew 2016 - Forum software by © MyBB