Welcome Guest, Not a member yet? Register   Sign In
less static website
#1

[eluser]elmystica[/eluser]
I've developed a few sites using CI and I'm loving it.
However, I've got a question.

Most of the time, a website main-navigation would be like

"home - product - service - about -contact"

I used to make a controller class called Home, and with functions for the other pages.
I also could make a single controller class for each page

Now I'm wondering, how do you guys handle that if you allow your client to add extra pages to that main menu? For instance, what if he would like to add a page called "testimonials"? How do you handle that? You shouldn't need to add an extra class or function, should you?
#2

[eluser]manilodisan[/eluser]
Do your clients code? We use a controller for each page in part since that's the logic of it..
#3

[eluser]elmystica[/eluser]
maybe I stated it wrong.

I'm using a rather static menu.
What I want to do is what I always did:
I insert my main navigation menu into a dbase ( usually with fields like "name, label, link, parent, template" ) and retrieve that in order to make my menu-view.

so, what if someone has a url like "www.domain.com/index.php?p=about"?
The old fashion way would be to have a index.php that reads that p-value, gets the template and loads the include-php for that page, and loads all the data for the "about" page.

In CI it goes like:
url: www.domain.com/index.php/about/
it loads the controller about.php and starts the model and view

My problem:
I allow clients to add extra items in the nav. For instance a page called "testimonials".

Old fashion way: easy: in the cms the client adds new page into the main menu table, choosing a template and fills in the data for the page. url would be like www.domain.com/index.php?p=testimonials

But how do you do it in CI? since you don't have a controller ready for every single page that someone can possibly add.
If it is a "subpage" like about/people or about/history, that's easy to implement in the about-controller. But since this is in the top level of your CI-Url, I don't get it how to handle this.
#4

[eluser]Bramme[/eluser]
Store the lot in the database, make a MY_Controller library and in the construct, query the database for user added links and send them to your views, with a class global var like $this->data, or maybe with the $this->load->vars() function.

In your views, you can link those user submitted links to a controller that handles the selected link and include the correct view, or get the content from your database.

If you don't want to use a separate controller for your database driven links, use a _remap function in your main controller. Or routes.




Theme © iAndrew 2016 - Forum software by © MyBB