Handle in controller category, subcategory,page_name |
Hi guys! I have a big question about handling stuff like category subcategory item_uri and so on.
First of all, I saw most the same topic in old EllisLab CI forum https://ellislab.com/forums/viewthread/170274/#862868, but that solution i don't like, i did same things many times and everytime it was horrable big controller and many repeated code. 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 am very need for your help. Every advice will be appreciable! I just did this all time that i think very bad and wrong and now i need to know how would be normal people doing this. More important will be the approach to this with codeigniter controllers (and mb routing) Thanks and sorry for my bad english ![]()
(12-05-2014, 07:20 PM)scion Wrote: So task is: 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() ) 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
many thanks for reply! But mb this is not exactly what i am asking about.
So how i am doing that now I have a controller name is "rubrics" Class Rubrics and method index. All variants of url path have the same start "rubrics" method public function index(arg1 = null, arg2 = null, arg3 = 0) and here i check how many args i have Code: $uri = 'rubrics'; So now you can see that all handle in one method controller and there i have many repeated code and it very huge! This is normal? Or maybe exists more readable and easy way to do same thing? Or maybe i missing something in your answer? Thanks! |
Welcome Guest, Not a member yet? Register Sign In |