CodeIgniter Forums
Main navigation and sub navigation question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Main navigation and sub navigation question (/thread-13949.html)



Main navigation and sub navigation question - El Forum - 12-12-2008

[eluser]copernicus[/eluser]
I searched the site and couldn't find a concise answer to this so,

I have a site with a main navigation:
Home About Projects Contact

And some pages have a sub navigation under the main one, for example the About page has:
Home About Projects Contact
|
FAQ History etc...

How would I make it so it would appear to be a "child" of the about page? So the URL would be www.mysite.com/index.php/about/faq

All the pages are being pulled out of a database and I am using one main controller with a view template where the main content is being pulled from the DB.

Thanks


Main navigation and sub navigation question - El Forum - 12-12-2008

[eluser]gstjohn[/eluser]
If I understand the question correctly, the simplest solution seems to be to have a controller named 'about' and a function within it named 'faq'. That should get you the desired URL.

Code:
class About extends Controller {
    function About() {
        parent::Controller();
    }
    
    // URL: http://www.somedomain.com/index.php/about -OR- http://www.somedomain.com/index.php/about/index
    function index() { ... }
    
    // URL: http://www.somedomain.com/index.php/about/faq
    function faq() { ... }
    
    ...
}



Main navigation and sub navigation question - El Forum - 12-12-2008

[eluser]Sarfaraz Soomro[/eluser]
If the above is not what you want, may be you should take a look at URI Routing.
URI Routing