$_Get[] With Cbaseurl

Hello Yii Experts!

I was working on the example creating a custom URL class - http://www.yiiframew…rl-rule-classes

Which is pretty much exactly what I’m trying to do with an Automotive application. So it’s almost pre-written for me :)

The one problem I’m running into is adding the path’ed variables into the query string ($_GET)

The comments in the code allude to all I need to do is set the value. Here is the method in the example

From the example




 public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)	

 {    	

       if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))    	

      {        	

               // check $matches[1] and $matches[3] to see        	

               // if they match a manufacturer and a model in the database         	

           	// If so, set $_GET['manufacturer'] and/or $_GET['model']         	

           	// and return 'car/index'     	

  	}     	return false;  // this rule does not apply 	

}

I have tried the obvious and simple prior to returning a valid URL

$_GET[‘make’] = ‘TESTING MAKE PARAMETER’;

But in the controller I don’t see anything in the ‘make’ of the _GET.

Anything special I need to do to make it part of the $_GET so in the controller I can use those variable? My controller has no named parameters, I’m just trying to pick them up by looking at $_GET[‘make’].

My sample method


	

public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)

 {

    	if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))	// /make/model

    	{

        	// check $matches[1] and $matches[3] to see

        	// if they match a manufacturer and a model in the database

        	// If so, set $_GET['manufacturer'] and/or $_GET['model']

        	// and return 'car/index'


			// check if matches are DEFINED! 

			// match for offset 1 is MAKE

			// match for offset 3 is Model

		

			if(isset($matches[1]))

			{

				if($matches[1] == 'ford')

				{

					if(isset($matches[3]))

						if($matches[3] == 'fiesta')

						{

							$_GET['model'] = $matches[3];

							return '/';	// match make model

						}

						else

							return false; // make ok, model fail, bad url

							

					$_GET['make'] = 'TESTING MAKE PARAMETER'; // $matches[1];

					

					return '/'; // matched model only		

							

				}

			}

    	}

    	return false;  // this rule does not apply

	}




Thanks

Sandy

Besides my sample code being wrong in the way it handles the 2 path parameters, the main problem was that in the controllers action I was looking at the $_POST for the data instead of the $_GET where it was actually being stored.

Need to take that step back and look at things, so many moving parts as they say :)

Onward with the custom URL rules, next to add database access to validate the make and model…

Sandy