If statements in Controller?

#5
[eluser]industrial[/eluser]
[quote author="jedd" date="1256085432"]Yes - I was just extending what you'd written in your first bit of code, within the controller.

And yes, again - controllers take the URL information (well, a generalisation, but it'll do now). Re-read the section in the user guide on MVC and specifically controllers, and keep on playing![/quote]

Hi again Jedd,

Took your advice and read through the user guide together with a book and some additional tutorials to seek further advice and examples regarding this. However I am still unsure of how to make it work.

Here's the current version of my "products" controller. I think that i have implemented it correcly.

Code:
<?php
class Products extends Controller {

    function index()
    {
        echo 'in index';    
        
        function shoes($sandals, $id)
        {
            if (!empty($sandals) OR !empty($sandals))
            {
            echo $sandals;
            echo $id;
            }
        }
        
         if (!empty($sandals) OR !empty($id))
         {
            $this->shoes ($sandals, $id);    
         }
        
         else
         {
            echo 'in else';
         }    
    
    }
    
}

Now when i Access either products/shoes/sandals/123 or products/sandals/123 (that i preferably would like to use in the future) i get a 404 back.

By visiting just /products/ i run into both echoes, and get both "in index" and "in else" printed out.

What is the best way to verify if a specific URI segment exist, and if so, pass it into an function?

Thanks!


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.