dynamic pages (from db) problem |
[eluser]gn90at[/eluser]
Hi together first of all: my english is bad. i am from austria...i hope u can read it. i am working with CodeIgniter since 2 weeks. i made a few small projects and now i want to create my own cms for one site (admin_panel). in the admin panel i can create a new site (eg "About") and i save the site with some content in a DB. (id, name, content). in the frontend, i got my own Sites Controller and a Site_model. Frontend: its like a newssystem (like in the tutorial of the CodeIgniter Userguide) but just for sites. The problem is the URL. when i got a Controller "Sites" it will produces URLs like this: http://www.mysite.com/sites/about But i want URLs like this: http://www.mysite.com/about i also got other Controllers with a fix URL (each of them got a own Controller): http://www.mysite.com/contact http://www.mysite.com/gallery http://www.mysite.com/news ... i think i need a function who checks if the controller exist and when not check if the site is in DB... something like that? i know the _remap() function of CodeIgniter. But it only takes the second segment of the URL. But i want a URL as i described above. is there any way to make a dynamic controller with such URLs? Hope u can help me. And again: sry for my english Best regards GN
[eluser]gn90at[/eluser]
one problem is now solved. the thing with the dynamic pages...i solved it with the _routes() function. the only problem i got is the URL: i want to make this: http://www.mysite.com/sites/about to http://www.mysite.com/about i cant do it in the routes.php because i got other controllers to like http://www.mysite.com/news. is there any way to check if a controller exist when yes load the controller when not load my Sites Controller? my current code if anybody want to see it: Controller Sites: Code: class Sites extends Public_Controller { My Sites_model: Code: class Sites_model extends CI_Model { is is what i got so far regards
[eluser]InsiteFX[/eluser]
You need to create "routes" within your ./application/config/routes.php file. i.e. Code: $config['default_controller'] = 'front'; CodeIgniter Users Guide - URI Routing
[eluser]gn90at[/eluser]
hi thx for your reply. yeah i know this solution. the problem is that my pages or in this case "Sites" are not hardcoded controller. it will be generated over an admin-panel. They came from the database. so i dont know wich sites-names will be created. the customer will create them. eg. he creates the sites: about, portfolio & team. (it will be saved in the DB) i dont want to edit the routes.php for each site. this should be done automatically. so i need a function to check if a controller exist...when yes call this controller when not check if a site is in the DB... and it has to be the first segment of the URL. http://www.mysite.com/portfolio u know what i mean? :/ |
Welcome Guest, Not a member yet? Register Sign In |