Wednesday, 4 September 2013

link to static page in codeigniter

link to static page in codeigniter

I'm new to PHP and CodeIgniter, and I'm having trouble setting up the
routing of static pages in my CodeIgniter app.
I have the About Us | Contact Us | Privacy Policy and many other pages in
my footer, which when the user clicks, should go to a url like
mysite.com\about mysite.com\contact mysite.com\privacy
You get the gist..
Here's what I've done in the footer div in the views folder
<a href="home/staticpages/about">About</a> |
<a href="home/staticpages/contact"> Contact Us</a> |
<a href="home/staticpages">Privacy</a> |
<a href="home/staticpages">Terms of Use </a>
Here's the function in a controller Home
public function staticpages($page)
{
if ( ! file_exists(APPPATH.'application/views/'.$page.'.html'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view($page, $data);
}
The static pages are just pure HTML content, with <p> fields and no
dynamic or javascript stuff. So I have them saved as .html; contact.html,
about.html and so on. I just want to load those pages' content in a
contentbody div I have created, between the header and the footer, and
that's the only thing that changes in the whole site for whatever the user
clicks.
When I goto http://localhost/myapp/home/staticpages/about
I get the
404 Not Found error The requested URL /dissekted/home/staticpages/about
was not found on this server.
And it's the one that the browser throws.

No comments:

Post a Comment