Welcome Guest, Not a member yet? Register   Sign In
url haendling for a cms
#4

[eluser]SitesByJoe[/eluser]
Alternate Solution: I'm assuming your storing your page content and meta data in your database.

I'm also assuming you want to have happy urls like:

Code:
http://mysite.com/pages/the-url-for-my-page

Here's the code from my "pages" controller to accomplish this:

Code:
<?php
class Pages extends Controller {

function Pages()
{
        parent::Controller();
        $this->load->model('Pages_model');
}

function _remap()
{        
        // is there a function name being passed?
        if (! $this->uri->segment(2))
        {
                redirect('');
        }
        else
        {    
                $slug = $this->uri->segment(2);
                $data['pages'] = $this->Pages_model->get_page_by_slug($slug);    
                
                $page = $data['pages']->row();    
                if ($data['pages']->num_rows() > 0)
                {
                        $data['title'] = $page->title;
                        $data['heading'] = $page->heading;
                        $data['description'] = $page->description;
                        $data['keywords'] = $page->keywords;            
                        $data['content_type'] = 'dynamic';        
                        $data['sub_content'] = array();

                        $this->load->view('templates/subpage', $data);
                }
                else
                {
                        echo ' no page found! ';
                }
        }
}

}


/* End of file pages.php */
/* Location: ./system/application/controllers/pages.php */

Hope this helps!


Messages In This Thread
url haendling for a cms - by El Forum - 05-23-2010, 08:19 AM
url haendling for a cms - by El Forum - 05-24-2010, 04:16 AM
url haendling for a cms - by El Forum - 05-24-2010, 09:24 AM
url haendling for a cms - by El Forum - 05-25-2010, 08:40 AM
url haendling for a cms - by El Forum - 07-06-2010, 06:10 AM
url haendling for a cms - by El Forum - 07-06-2010, 07:23 AM
url haendling for a cms - by El Forum - 07-06-2010, 09:38 AM
url haendling for a cms - by El Forum - 07-06-2010, 09:53 AM
url haendling for a cms - by El Forum - 07-06-2010, 10:14 AM
url haendling for a cms - by El Forum - 07-06-2010, 10:17 AM
url haendling for a cms - by El Forum - 07-06-2010, 10:59 AM
url haendling for a cms - by El Forum - 07-06-2010, 11:38 AM
url haendling for a cms - by El Forum - 07-06-2010, 08:25 PM
url haendling for a cms - by El Forum - 11-05-2010, 01:57 PM
url haendling for a cms - by El Forum - 11-09-2010, 07:23 AM
url haendling for a cms - by El Forum - 11-09-2010, 08:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB