Welcome Guest, Not a member yet? Register   Sign In
Quick _remap tutorial || code evaluation
#11

[eluser]SitesByJoe[/eluser]
Here's another example of _remap:

I use it in my "pages" controller which feeds from my CMS data to do the same thing you were trying to do there in the beginning.

Code:
function _remap()
{        
    // is there a function name being passed?
    if ($this->uri->segment(2))
    {    
                // grab the url segment (e.g. /name-of-my-page/)
        $slug = $this->uri->segment(2);
                // get the match from the database
        $this->load->model('Pages_model');
        $data['query'] = $this->Pages_model->get_page_by_slug($slug);        
                // dump our results into an object (or a false)
        $page = $data['query']->row();    
                // use query results to fill in page meta data
        if ($data['query']->num_rows() > 0)
        {        
            $data['title'] = $page->title;
            $data['description'] = $page->description;
            $data['keywords'] = $page->keywords;            
            $data['content_type'] = 'dynamic';            
            $this->load->view('templates/subpage', $data);
        }
        else
        {
            echo ' no page found! ';
        }
}

Its been working pretty well for me and scales well since I never know what the page slug may end up being!
#12

[eluser]BLymoth[/eluser]
[quote author="xwero" date="1224184384"]just move it one segment Smile
Code:
$route['(\w{2})/(productions)/(current|factual|kids|drama|events|co)(.*)'] = '$2/genre/$3$4';
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];
the route for the productions has to come before the catch-all route[/quote]

Cheers mate... exactly what I was looking for
#13

[eluser]Josssi[/eluser]
Hi people, i saw there solutions of the problems with correct uri, i have problem with them. In view I have table with products, and I want to every name of product was link, which calls edit view of this product. So to the link i need to add as the third param product_id, but when I have in url after base_url ...product/edit/some nubmer, then if I click in menu for example HOME, my new generated uri is ...product/edit/home and its bad. It is overwritten just third param and last two stays. I need correct uri on cklick on home just
....home... Wher should be a problem? Rewrite modul I have turned on.
#14

[eluser]InsiteFX[/eluser]
If you want to edit a record then your url needs to point to your edit method in your controller!

If you click Home on your menu then it will goto to your Home method...
Code:
public function edit($id)
{
    $this->auth->register(FALSE, TRUE, $id);
}




Theme © iAndrew 2016 - Forum software by © MyBB