![]() |
Static Pages with CI urls and Dynamic Data - 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: Static Pages with CI urls and Dynamic Data (/showthread.php?tid=5844) |
Static Pages with CI urls and Dynamic Data - El Forum - 02-05-2008 [eluser]philpalmieri[/eluser] a while back we needed the ability to have some static pages, but to give them access to the CI models... This allowes a couple people in the office, and our clients to add files and hierarchy to the /views folder, and have it reflected on the domain with the proper URL, also keeping the .htaccess re-writes in place. First step setup your .htaccess if it isnt already: We are ignoring index.php, robots and a folder called global that we keep scripts, css etc in) Code: /*.htaccess */ Next Setup a controller called pages.php This is where the fun is, load the models/helpers you want your static pages to have access too Code: /* controllers/pages.php */ Now, to bring it all together, we need to modify the config/routes.php file so that the system will look for a controller first, then fall back on a static page, then to an error.. Code: /* config/routes.php */ finally, create a folder in your views folder called /views/test/. in there put an index.php, a foo.php etc. and you will be able to access them by going to site.com/test or .com/test/foo.html (we re-write the .html to php so it looks like static content This is our static page, that our designers now have access to loop through dynamic data like recent blog posts, new products etc. Code: /* static page - this would be full HTML, but i cropped just a dynamic section for the post */ Well you get the idea Phil |