Welcome Guest, Not a member yet? Register   Sign In
SEF urls from the database: please help, i've already spend 6h trying to find it out :s
#5

[eluser]Tottys Design[/eluser]
[quote author="cahva" date="1258144190"]Hi,

I did this with _remap() so all methods will go through it. Heres an example that I use in one of my projects. It uses datamapper ORM and I have a field called "slug" that containts the SEF path to the page. I removed some of the stuff but you should see how it works:

Code:
<?php
class Pages Extends Controller
{
    function __construct() {
        parent::Controller();
    }

    function _remap($method)
    {
        if ($method == 'index')
        {
            $p = new Page();
            $p->get_by_frontpage(1);
        }
        else
        {
            if ($this->uri->total_segments() > 2)
            {
                $segs = $this->uri->segment_array();
                array_shift($segs);
                $realpage = implode('/',$segs);
                $p = new Page();
                $p->get_by_slug($realpage);
            }
            else
            {
                $p = new Page();
                $p->get_by_slug($method);
                $realpage = $method;
            }
        }
        
        // If page does not exist
        if (!$p->exists())
        {
            show_404($realpage);
            exit;
        }
        
        /* Removed */
        
        $this->load->view('page',$data);
        
    }
    
}
[/quote]

Thanks Wink


Messages In This Thread
SEF urls from the database: please help, i've already spend 6h trying to find it out :s - by El Forum - 11-16-2009, 09:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB