Quantcast
Channel: PHP Website Development » DD
Viewing all articles
Browse latest Browse all 2

How to create a custom page with Codeigniter, not as control

$
0
0

I have a website which is built on Codeigniter and I want to create some pages with information like terms or privacy, their address should be:
http://domain.com/terms
http://domain.com/privacyMy question is: should I create for each page a controller? In CMS for example, if I add a page it has to create a ‘pysical’ page on the server (CMS which is built on Codeigniter)?
………………………………….

For static pages like a Privacy Policy or Terms of Service page where they don’t really fit under any other controller I usually create a “content” controller that looks something like this:
class Content extends CI_Controller {

public function privacy_policy()
{
$this->load->view(‘privacy_policy’);
}

public function terms_of_service()
{
$this->load->view(‘terms_of_service’);
}

}Then I add some routes to remove “content” from the URL:
$route['privacy-policy'] = ‘content/privacy_policy’;
$route['terms-of-service'] = ‘content/terms_of_service’;That way you don’t need to create a new controller for each page and you can keep your static pages organized in a single spot.
………………………………….

Something I do is make your policy statements as a DL, DT, DD. hide the DD with jquery, show the DD then on a click to the DT. Then have the DD popup as a modal
The entire thing is contained in the footer. No need for anything to do with the controller


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images