If statements in Controller?

#7
[eluser]industrial[/eluser]
[quote author="jedd" date="1256162606"]Okay, two things.

First, start using a constructor - as per the template code shown in the manual for controllers. Otherwise it'll bite you really soon when you start using CI classes.

Second, and it's what is causing your problem here - index() should not be the parent to the other functions or methods you are using there.

index() typically is empty or remaps back to the main or default function you have in your controller - simply because of the ambiguity of taking parameters to index() versus using a different method name (they both look the same in the URL).

Now, when you hit the url products/shoes/sandals/123 - it's looking for Products controller (which it can find) and then the shoes method (which it can't). So, 'lift up' shoes a level, so that it's peer of the index() method.[/quote]


Thanks again Jedd! You really are a great guy!

My basic idea for using empty to check the variables, was to make the function idiot safe. If either of the variables werent posted, we could control the result instead of posting an error.

What happens now is that I get "Missing argument 2 for Prod:Confusedhoes()" + "Undefined variable: id" when url "prod/shoes/sandals/" is called, is just fully understable, but how can i get around it?

Do I already have one foot inside the remapping feature to make this happen, as shown in this article: http://www.anmsaiful.net/blog/php/codeig...nefit.html ?

Thanks for your time!


Messages In This Thread
If statements in Controller? - by El Forum - 10-20-2009, 12:27 PM
If statements in Controller? - by El Forum - 10-20-2009, 12:33 PM
If statements in Controller? - by El Forum - 10-20-2009, 01:19 PM
If statements in Controller? - by El Forum - 10-20-2009, 01:37 PM
If statements in Controller? - by El Forum - 10-21-2009, 09:47 AM
If statements in Controller? - by El Forum - 10-21-2009, 11:03 AM
If statements in Controller? - by El Forum - 10-21-2009, 12:31 PM
If statements in Controller? - by El Forum - 10-21-2009, 03:24 PM
If statements in Controller? - by El Forum - 10-22-2009, 06:13 AM
If statements in Controller? - by El Forum - 10-22-2009, 08:46 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.