Tuesday, May 26, 2009

Re: [phpXperts] Cakephp Controller method



You can use $uses variable to your controller for getting another controller and it's functions.

the code will be like --
 
class ProfilesController extends AppController
{
    var $name = 'Profiles';
   var $uses = array('Profile','Address');
 
  function viewprofile(){
 
  echo $this->Address->view();

  }
}

On $uses variable you must have to define both the model names of current controller and another controller.

Humayun Kabir,
Analyst Programmer
SureSoft Technology Limited

--- On Fri, 5/22/09, Anupom <anupom.nsu@gmail.com> wrote:

From: Anupom <anupom.nsu@gmail.com>
Subject: Re: [phpXperts] Cakephp Controller method
To: phpexperts@yahoogroups.com
Date: Friday, May 22, 2009, 10:02 AM

hi milan_018.

you can use Controller:: requestAction( ) method for this. take a look at the doc here http://book. cakephp.org/ view/434/ requestAction
but as the doc says if used without caching requestAction can lead to poor performance. it is rarely appropriate to use in a controller or model.

i would suggest you to create a component and reuse it across your controllers.

thanks.

On Fri, May 22, 2009 at 10:13 AM, milan_018 <milan_018@yahoo. com> wrote:


Hello experts,
I am in need to get your helps.

Can you tell me "how to call a controller method/action from another controller in cakephp?"

For example i am in "viewprofile" action of the controller named "ProfilesController". Now from this controller i need to call "view" method of the controller "AddressesController".

How to do that ?




--
Anupom
http://syamantics. com

__._,_.___
Visit phpXperts website at www.phpxperts.net
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Need traffic?

Drive customers

With search ads

on Yahoo!

Group Charity

Be the Change

A citizen movement

to change the world

.

__,_._,___

No comments: