Building pages dynamically from a database. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Building pages dynamically from a database. (/showthread.php?tid=55119) |
Building pages dynamically from a database. - El Forum - 10-11-2012 [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 Building pages dynamically from a database. - El Forum - 10-11-2012 [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 |