SEF urls from the database: please help, i've already spend 6h trying to find it out :s

#1
[eluser]Tottys Design[/eluser]
Hy,

I would like to have my urls like this, not hardcoded.

only gallery is wrote in the route array

www.mysite.com/gallery/dynamic_folder_form_db1/dynamic_folder_form_db2/dynamic_folder_form_db3

how can i do this?

This is my code:
Code:
function getSubContents(){
        $vars =& func_get_args(); // this should get the dynamic_folder_form_db1, dynamic_folder_form_db2, dynamic_folder_form_db3 but doesn't work :S
        return $vars;
}

#2
[eluser]überfuzz[/eluser]
Have a method looking throw the url. Use the result to query the database.

#3
[eluser]Tottys Design[/eluser]
Heh, thanks. Now I get it, I was using a bad .htaccess and was hidding all my vars. Now I'm facing some troubles with the breadcrumbs, and links to the parent page, but i think i can fix them Smile

#4
[eluser]cahva[/eluser]
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);
        
    }
    
}

#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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.