Welcome Guest, Not a member yet? Register   Sign In
Custom controller method used via route
#1

[eluser]JanCK[/eluser]
Hi,
I'm quite new to CI so maybe I just overlooked something:
I created a custom controller and put it in the libraries folder of my app and set it as default_controller.

MY_CONTROLLER with public function lang($language)

When I set several routes to subfolders (controller/subconroller) and the sub controllers get involved via
routing, they do not interprete the next to last and last segment as method and value of the default_controller.
Does anyone know how to solve this?

controller/lang/en - method
controller/subconroller/lang/en - ignored

Thanks
#2

[eluser]überfuzz[/eluser]
Mhmm, to be honest with you... I didn't get that.

Short about CI - controllers
1. Put controllers in the controllers folder
2. If you have a sub folder, you'll reach the controllers like this: www.site.com/subfolder/controller/function/etc..
3. If you need the same info in many controllers use a MY_Controller and extend controllers with it.
#3

[eluser]JanCK[/eluser]
Thanks so far, you're right. Sometimes I tend to riddle.
When I try to use a URI like /subfolder/severeal_segments.../function/value
I can't use the function. In fact I'd like to extend the usual segment chain 'controller/function/value' because I need the
last two segements to be interpreted as function and value. I guess defining routes would be helpfull but how if I'm right?
($route['products/(:any)/lang/(:any)'] = "products/$1/lang/$2" or so?)
#4

[eluser]JanCK[/eluser]
Solved – thanks. I used the third segment as usual as a function and the value of "lang" as trigger for $this->lang(nextsegment).
Seems dirty but works fine.




Theme © iAndrew 2016 - Forum software by © MyBB