Welcome Guest, Not a member yet? Register   Sign In
Deep level argumenting
#1

[eluser]RobertR[/eluser]
I think, this probably is novice question, but I am novice in CodeIgniter Smile

Well here is the problem, I'm trying to make categories and subcategories (dynamically generated) for store, and the main problem is that, I could manage to set different options to main category with _remap function in my controller. But, if I am trying to get deeper, then the same _remap function applies, and I am stuck there.

For example, the main category uri is http://project.com/store/fruits/, but for the subcategory, of course - http://project.com/store/fruits/apples.

I want to apply different view to 3rd segment, and still be able to control main category (fruits) with _remap function.

I want to use one controller over and over, but I think, it must be crazy to copy and paste the same function content for all subcategories (hundreds of them, disguised).

Maybe there is some way to do that, but I can't find out how... Help here! Smile

/Rob
#2

[eluser]Lotus[/eluser]
remap has a second parameter $params which is an array of the other parameters passed in. So...
Code:
function _remap($main_category, $params = array())
{  
  // do stuff with main category...

  while ($subcategory =  array_pop($params))
  {
    // do stuff with each sub category
    // each iteration of loop is another level deeper of sub categories
  }
}
#3

[eluser]RobertR[/eluser]
All right, and what should be those other parameters? Smile
#4

[eluser]Aken[/eluser]
The parameters are pulled from your URI. http://ellislab.com/codeigniter/user-gui...passinguri
#5

[eluser]RobertR[/eluser]
Okey, I think, I got the idea. I'll try Smile




Theme © iAndrew 2016 - Forum software by © MyBB