Sunday, March 27, 2011

Re: requestAction wants view from requested controller

try this:

<?php

function parse()
{
        $this->autoRender = false;
   //using the url, get a controller's action data
        $data = $this->requestAction(array("controller" => $this->controller, "action" => $this->action), array('pass' => array($this->actionParams)));
   $this->set("data", $data);
        $this->render("/elements/api");
   return true;
}

?>
--
Lep pozdrav, Tilen Majerle



2011/3/27 mlecho <saltlessbread@gmail.com>
hi, i am building an api plugin for my webapp...i have almost
everything working well except for the actual rendering. The plugin
will authenticate and then essentially, from the url, do an action ,
grab the data, and return it as xml or json. An exmaple url might be:
http://webapp.local/api/?token=1234&params=4&method=users.view

the plugin will validate a user by token, then call the Users
controller view action, passing 4.

In my plugin beforeFilter method, i've called

$this->layout = "api";
$this->autoRender = false;

and the actual logic to get the data looks like:

function parse()
       {

               //using the url, get a controller's action data
               $data = $this->requestAction(
                       array("controller"=>$this->controller,"action"=>$this->action),
                       array('pass' => array($this->actionParams))
               );
       $this->render("/elements/api");
               $this->set("data",$data);
       }

if i debug $data, everything i expect is there. However, cake's
warning is i am missing the view for my plugin controller...but it's
there. Thoughts?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: