Welcome Guest, Not a member yet? Register   Sign In
Handle in controller category, subcategory,page_name
#2

(This post was last modified: 12-06-2014, 04:37 AM by trentramseyer.)

(12-05-2014, 07:20 PM)scion Wrote: So task is:

I have on a site category, subcategory. Obviously they have something like post (or product, whatever) and of course i using pagination segment.

So url will be next few

category/post_uri
category/pagination_segment
category/subcategory/pagination_segment
category/subcategory/post_uri

And now i need to know guys how you are handle this all !??? What is the best approach to deal with this all?


I have attempted to handle the issue stated by the forum link several different ways:
http://www.testsite.com/category/sub-category/page-name
http://www.testsite.com/category/page-name
http://www.testsite.com/page-name

Updating the routing, hooks, etc...I came to the conclusion, it was never clean and ultimately "broke" codeigniter's way of doing things.

For a Minimum.. make sure the first Segment is a controller

Then in that controller use the _remap function, by placing the below in your controller, it will check to see if the second segment is an actual method inside the controller, if not you can make it run a function all the time passing parameters.

Remap information: https://ellislab.com/codeigniter/user-gu...llers.html

PHP Code:
public function _remap($method$params = array() )
    {
         if(
$method <> "index")
 
               {
             if (
method_exists($this$method))
            {
                return 
call_user_func_array(array($this$method), array($params));
            }    
        }
        
$this->index($method,$params);
    } 



I would come up with a generic format you like to handle controller/method_or_variables and stick with it. so the above would be
http://www.testsite.com/category/sub-category/page-name
http://www.testsite.com/category/page-name
http://www.testsite.com/pages/page-name
Reply


Messages In This Thread
RE: Handle in controller category, subcategory,page_name - by trentramseyer - 12-06-2014, 04:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB