Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2008, 09:06 AM
Junior Member
 
Join Date: Jun 2008
Posts: 2
Default using function from a controller in an other controller

Hello,

I have a question about using an function from one controller in to an other controller. Lets say i have a productController with the method getProductInfo and i have an userController. Now i want to get all the info for the users products so i want to use the function getProductInfo from the productController but i'm in the userController...

I've tried to make an new productController then i get a error from the __construct..

I just want to use one function from a other controller in to my userController.. Can somebody help me?

Thanks and regards!!

Last edited by Daniel B : 06-17-2008 at 01:34 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-17-2008, 02:13 PM
Junior Member
 
Join Date: Oct 2007
Posts: 26
Default

Hi Daniel,

It sounds to me like the method should really be in the model. If you put the method in the model and then require the model, you can then call the method to retrieve your data.

Is that what you mean?

I hope this helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-17-2008, 03:01 PM
Junior Member
 
Join Date: Jun 2008
Posts: 2
Default

Putting the method in the model should do the trick, thx for the answer. I need to study the MVC model a bit more!

Thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-18-2008, 12:10 AM
Junior Member
 
Join Date: Oct 2007
Posts: 26
Default

Daniel,

Glad I could be of assistance. Here is a link to a quick start tutorial using MVC and ZF. I am sure there are others, but this is one of the first ones that I came across.

Typically, any methods that you want to access data should be stored in the apropriate model file.

There are several examples and tutorials.

Best of luck to you and if I can help you any further please feel free to just ask.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-01-2008, 12:43 PM
Junior Member
 
Join Date: Jul 2008
Posts: 6
Default

try to use the forward functio n , example :

Quote:
...
.. // controller 1
public function func1Action() {

$this->getRequest()->setParam("message" Hello world !");
$this->_forward("funct2","controller2");

}
and in controller 2
..
Quote:

public function func2Action() {

$msg = $this->_getParam("message");
echo "my messages is :" . $msg ;

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:05 AM.