Building pages dynamically from a database. |
[eluser]Unknown[/eluser]
Hey guys, One thing that is slightly baffling me at the moment is how you would go about creating pages dynamically from a database. Let me try and explain. If i had a database with a table of pages for example "home", "News", "Portfolio". that contains the title, content...etc. Normally to create a page you obviously create a controller then you could select the data and dump it out using the controller. Is there a way to make it so you can just add new pages to the database then navigate to the url+slug without creating a controller each time? If someone could try to explain it to me that would be great! i have had lots of people try to explain how to do it using dynamic routing and such but i am a little confused! Thanks sorry if i didnt explain myself as well as i had hoped! Simon
[eluser]alexwenzel[/eluser]
An Example: routes.php Code: $route['display/(:any)'] = 'controller_pages/display_page/$1'; controller_pages.php Code: class Controller_Pages extends CI_Controller { Now you can call: http://your.app/display/home http://your.app/display/news http://your.app/display/portfolio |
Welcome Guest, Not a member yet? Register Sign In |