Welcome Guest, Not a member yet? Register   Sign In
Static Pages
#1

[eluser]Unknown[/eluser]
Perhaps a silly question, how do you code to handle static pages?

I've searched and come out with some .htaccess methods, which I don't want as I would still use the common header / sidebar / footer templates for all pages.

I'm thinking of creating one single controller for handling all static pages and just loading different view files.

e.g, my nav menu may look like this:
Home
Member (<-- where the programs in)
Info
- item1
- item2
...
Service
- item1
- item2
- ...
Other Pages....

For now I've created a Page controller, which _remap to index() and load different page views using switch case (this is not good and need a lot of effort to create cases for every single page)
e.g. index.php/page/info would load the "info" page
but how do I code so that index.php/page/info/item1 would lead to "info-item1" page?
(yes I want the url looks nice and in levels...)

Thanks all for your help / insights
#2

[eluser]mattpointblank[/eluser]
index.php/page/info could map to a page() method which would load a view file with whatever your parameter is.

So when you add a new view called 'contact-us.php' or whatever, just link to index.php/page/contact-us, then in your method just do:

Code:
function page($view)
{
    // load header etc here
    $this->load->view($view);
}

Just make sure you handle it gracefully if a page doesn't exist (might be worth doing some security cleaning on the $view var too, although CI should remove anything dodgy.
#3

[eluser]sophistry[/eluser]
check site_migrate in the wiki for how to use _remap() to do static pages in a nice way.

there is a link in my sig.

post in the forum thread connected to the wiki page for any issues.

cheers.
#4

[eluser]Unknown[/eluser]
Thanks both for the tips.
That site_migrate script is really useful.
I end up putting it in my default controller that makes the url looks even better.




Theme © iAndrew 2016 - Forum software by © MyBB