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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-05-2008, 12:20 PM
mel mel is offline
Junior Member
 
Join Date: Feb 2008
Posts: 11
Default sharing views across controllers

I currently have 4 controllers, each with the same set (4) of actions. The view scripts for each action is basically the same across different controllers, and I'd like to avoid having 16 scripts in 4 different folders. The view script structure is (the standard setup):

views/scripts/controller1/actions 1 - 4
views/scripts/controller2/actions 1 - 4
views/scripts/controller3/actions 1 - 4
views/scripts/controller4/actions 1 - 4

What I would like to have is:

views/scripts/actions 1 - 4

I know I can just add $this->render('action', null, true); to each action, but that seems a little unnecessarily repetitive.

How else can I do this? I feel like I've missed something in the documentation, but I just can't see where the controller name is added to the script path, or how to avoid that happening.

Thank in advance for any help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-10-2008, 02:13 PM
Member
 
Join Date: Aug 2007
Location: Sweden
Posts: 52
Send a message via MSN to Leif.Högberg
Default

Place the code below in your bootstrap and it should work the way you want it to.
This would affect all of your controllers tho. Maybe that is not what you are after.

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($vi ewRenderer);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-10-2008, 02:28 PM
mel mel is offline
Junior Member
 
Join Date: Feb 2008
Posts: 11
Default

Thanks for that, it does sound like just what I want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-11-2008, 01:15 PM
mel mel is offline
Junior Member
 
Join Date: Feb 2008
Posts: 11
Default

Thank you

I'm not sure how I missed this in the doc:
Zend Framework: Documentation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-11-2008, 01:24 PM
Member
 
Join Date: Aug 2007
Location: Sweden
Posts: 52
Send a message via MSN to Leif.Högberg
Default

The manual is hard to navigate sometimes

Glad I could be of some assistance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-18-2008, 04:29 AM
Junior Member
 
Join Date: May 2008
Posts: 6
Default

Thank you!
__________________
Nắng sớm nhớ cha nợ cha một sự nghiệp
Chiều ta thương mẹ nợ mẹ một nàng dâu
----------------------------
Diễn đàn Nghệ An - Hà Tĩnh:
http://nghe-online.org/forum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-18-2008, 03:45 PM
Junior Member
 
Join Date: Jun 2008
Posts: 18
Default

AddViewPath would probably be a better addition rather then set.
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 11:38 AM.