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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-18-2007, 05:49 PM
jrh jrh is offline
Junior Member
 
Join Date: Dec 2007
Posts: 2
Default view/controller help

What is the best way to make calls to different actions in the same page? On my index page I may want to call sayhiAction within that page.

Also, what is the best way to use Zend_View in the case where noViewRenderer = true.

My index controller looks like this, should I extend Zend_View so I don't have to set the script path in every action or is there a better way to do this?

PHP Code:
class IndexController extends Zend_Controller_Action
{
    public function 
indexAction()
    {
        
$view = new Zend_View();
        
$view->setScriptPath('../application/views/scripts');
        
$view->title "Welcome";
        
$view->content "Hello, World!";
        echo 
$view->render('main.phtml');
    }
    
    public function 
redirectAction(){
        
$this->_redirect('/');
    }

    public function 
sayhiAction(){
        return 
"Hi";
    }

Thanks for the help.

Last edited by jrh : 12-18-2007 at 05:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-19-2007, 05:39 PM
jrh jrh is offline
Junior Member
 
Join Date: Dec 2007
Posts: 2
Default Update

I have been able to achieve some of what I would like to do by modifying the action helper in the boot strap (index.php)

PHP Code:
$view = new Zend_View();
$viewRenderer Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view)
             ->
setViewSuffix('phtml')
             ->
setNeverController(true)
             ->
setScriptAction('main')
             ->
setNoRender(true); 
My indexController now looks like this

PHP Code:
class IndexController extends Zend_Controller_Action
{
    public function 
indexAction()
    {
        
$this->view->title "Welcome";
        
$this->view->content "Hello, World!";
        
$this->render('main');
    }

    public function 
redirectAction(){
        
$this->_redirect('/');
    }

So I am rendering main.phtml. I would like to not to have to call $this->render('main'), but when I try to set setNoRender(false) for some reason it tries to render index.phtml even though I set setScriptName('main'). Any suggestions?
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 06:27 PM.