How do you make a simple navigation in Code Igniter? I keep tripping up on all these pseudo folders. Originally I was looking to make something that dug through a folder and grabbed all the file-names, then placed them in an array to order them into a nav bar.
Problem is, it seems that CI uses public functions for the pseudo folder in each page. Such as “public function aboutme()” would work out to xxx.xxx.xxx.xxx/index.php/[classname]/aboutme. This poses a problem for me, because when making links like test works out to xxx.xxx.xxx.xxx/[classname]/contactme.
Is there a better, dynamic way to make a nav bar without using a database? I CAN use a database, but I’m trying to learn CI and since I’m already well-versed in MySQL I wanted to find a way to do this some other way.
Maybe a custom route would help you?
http://codeigniter.com/user_guide/general/routing.html
I’m not sure the structure of your application, but if you are using multiple controllers, it won’t really help and there isn’t really an easy way to do it “automagically”. The best thing would be to come up with some way to manage the navigation items, such as a database (as you said).
If you’re only using one class, you can use PHP’s
get_class_methods()on the class.This is a very simplistic way to do it, and you’ll have to filter out private methods and the
__constructmethod as well.