views:

37

answers:

2

is there an easy way to access the url helpers from the models like the ones available in the controllers
i mean in the controllers there is an easy way to generate urls like this :

$this->_helper->url(controller,action,null,params);

now what i need is an easy way to pass urls direclty from the model to the views , for now what i am doing is to pass the CONTROLLER,ACTION AND PARAM as an array to controller then replace the text in the controller with with the helper url in the controller but i want a better way is there one?

A: 

The Model should not access the View, nor having to know about it.

If you have to do work that is related to the presentation layer, either use an Action Helper or a View Helper. The data you are processing is fully available in the Controller, so there should be no need to pass it from model.

Gordon
since any CRUD operations in the persistence or db are done in the models i don't want to have ugly(mysql or any db messages displayed to the user ) messages displayed to the user rather i want the user to update his/her data accordingly (i don't want any kind of CASCADING on the DATA)
jspeshu
@jspesh umm, yeah, but how's that related to the question?
Gordon
then when a user tried to do some CRUD operation rather than displaying the ugly mysql error i want to notify(show) the user that he also should update the related data and provide the user with a link(from the model) to do the update ...
jspeshu
jspeshu
@jspeshu I still dont understand how that is related to the question. Please [update your question](http://stackoverflow.com/q/3606480/208809) with the information you gave me here (and maybe delete your comments), so other people can see what you are actually up to. Sorry, but I dont get it.
Gordon
A: 

actually it's a bit specific to my problem but i made work it this way

$check['msg'] == will contain the error or success message  

from the models i pass the link that causes the problem

$messages['link'] = array('action'=>'index','controller'=>'trip','params'=>$tripid );  

an on the controllers

$check['msg'] = str_replace('%link%',$this->_helper->url($check['link']['action'],$check['link']['controller'],null,array('id' => $check['link']['params'])),
                                $check['msg']);

$this->_flashMessenger->addMessage($check['msg']); 
jspeshu