Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Zend Framework: Controllers in separate directories -


i'm quite new in zend framework, learning. i've encountered following problem, don't know if solution :)

i've created application uses widgets. widget class implements widget_interface , executed widget_manager.

widgets can loaded via widgetcontroller (which calls widget_manager, etc). problem encountered is: widgets can configured, , make code more transparent, i'd widget have own controller (currently, class). problem is, i'd widget configurations addressed via widgetcontroller, , passed specific widget controller.

an example: let's i've got widget named 'scrobbler'. when configuring in ui, i'd make ajax request updated settings. make request http://myapp.com/scrobbler/update-info/, framework run scrobblercontroller , i'd process information here on. idea make request on http://myapp.com/widget/update/scrobbler/, framework runs widgetcontroller. widgetcontroller call scrobblercontroller , pass other parameters.

i'm aware of _forward() function in zend_controller, i'd have widget controllers , application's controllers separated (let's application controllers in /application/controllers , widget controllers in /application/controllers/widgets).

is possible make , have add zend framework configuration? hope didn't complicate :)

nice day

edit: solved using modular structure, , moved common classes root directory.

you coud utilize controller helpers instead of controllers in case. let's widgetcontroller responsible updating types of widgets. updateaction need find information on widget type wish configure, scrobbler parameter. need name parameter can accessed easily. can done either adding route or adding name before scrobbler in uri.

solution 1: add route:

in bootstrap:

public function __initroutes () {     $route = new zend_controller_router_route(         'widget/update/:type',         array (             'controller' => 'widget',             'action' => 'update'         ),         array (             'type' => '[a-z_-]*'         )     );     /* @var $fc zend_controller_front */     $fc = $this->bootstrap('frontcontroller')->getresource('frontcontroller');     /* @var $router zend_controller_router_rewrite */     $router = $fc->getrouter();     $router->addroute('update-widget', $route); } 

solution 2: add parameter name in uri:

make requests /widget/update/type/widgetname instead.


now, in widgetcontroller::updateaction, can fetch widget update using $this->_getparam('type').

so code like:

class widgetcontroller extends zend_controller_action {   public function updateaction ()   {      $widgetname = $this->_getparam('type');      $this->view->result = $this->_helper->widgets->update($widgetname);   } }  class app_controller_helper_widgets extends zend_controller_action_helper {   public function update($widgetname)   {      $widgetmanager = new app_model_widgetmanager();      $widget = $widgetmanager->load($widgetname);      $widget->setoptions($this->getrequest()->getparams());      return $widget->save();   }  } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -