Hello everyone, I am once agian running into a problem with something that's normally simple, yet lovely cakePHP has to make all so very hard.

I'm once agian tasked with improoving the bookmarking application on our website. This time I am suppose to have the url save the date: start & stop parameters within the url and use the url save mechanics of my bookmark tool. However cakephp isnt making this easy.

I tried using $this->request->query['action']; as well as $this->request['action']; even $this->params['action']; but none of this works. Any ideas on how to make this work using cakephp 2.3?


did you try $this->request['param']; as suggested here?

I really don't understand why? cake php would deprecate such a useful function like the array access


Ok so I was able to get url to pass to the controller using $this->params->query['param'] however, cakephp still tells me the variable is undefined, despite the fact I'm clearly printing it to the page... which is also preventing me from passing the variable to the view...

When sending data from logic side to the view side, we can safely assumed that pretty much all frameworks and templating engines have identical coding convention, .

Like smarty, dwoo, twig just to name a few, the data are passed in this convention

$this->FrameWork_method('string_variable', $value_of_string_variable_from_anywhere');

So, for our Cake it can be something like this in the controller


The 'set' method made the string variable available for view's disposal. To display the url on the view, it can be coded as simple as this

    <!-- Here is the code for the url -->

    Url: <?php echo $url ?> 

I've been doing that and sadly once the focus is switched from the controller to the view the values set to those variables vannish. However the indexes in the array are allowed to stay....

Makes no sense to me O_O, I'm assuming it has to do with something set up in the config.php by the admin, but I honestly just don't know. (Never encountered this problem before with passing hardcoded variables or even ones transfered from an ajax call.

How did they set-up the indexes in the array? You might be able to add it there..

I believe CakePHP allows this type of data assignment.

$this_Data = array(

            'string_var1' => $value,
            'string_var2' => $value_two,
            'string_var3' => $value_three,
            'url'   => $this->request['param']


If you can add the url data in the array, you can easily follow the existing reiteration in the view side to display the url.

I understand your situation. Sometimes previous coders or "ADMIN and BOSS" would do a pretty lazy approach.. something like this.


## or a hard coded const from the model file

## common practice they don't even make a comment on where the method is coming from. 

I hate it when people do that, because it will be difficult to reference variable values on the view.

You can also try looking at your application model file.. look for something like this

class Name_Of_Your_Application extends AppModel{

 public $YourApplicationVar = array(
    'Something' => array(
        's_var1'  => 'SomethingHere',
        's_var2' => 'somethingHere_again',
        ## watch out for array like this
        's_array' = array('s_array1'=>'s_array1_value', 's_array2' => 's_array2_value' )

Ok so after much struggle I was finally able to get the whole bookmark system to work. Keep mind this is normally would've of been a simple task. However I had an added handicap of using the jquery tabs too. So I feel its important I post how to do to this using it below.

First thing to note is when working with the tabs your url bar will not change from the outset. So the document.window function in javascript becomes all but useless for any page that uses it. Also note with Cakephp alot of built in encryption securty is used therefore any call make by ajax generally goes encrypted. Therefore making the use of a request_uri also very hard. You could use 'get' instead of 'post' but you will still run into problems pulling out the correct callback. (if you have a ton of callbacks going from a single event listener)

I came to the conclusion the best way to make this work is to "force" a url to be used that matches your specs. You can do this using session variables and the religous use of the app_controller. Add all your funcationality for the 'url reader' into the app_controller in your before filter this way, the url is read before the jgrid has the ability to troll with your url bar.

Now there is more to if that is if your using jqgrid but i suspect most people wont wanna go this far. If you wanna know more you can msg me asking me for help!