Page 1 of 1

Zend Framework - complex view

Posted: Fri Nov 25, 2011 7:56 am
by michalowskiego
Hi,

I'm trying to create a profile page with some profile info, picture and tabs. I need tabs to work with and without ajax.
This is what I came up with. The ajax part will come later I just want to ask is this correct in terms of mvc?
Is there a better way you can show me?

Code: Select all

class ProfileController extends Zend_Controller_Action
{
	public function showAction()
	{
		// Get params from request
		$params = $this->_request->getParams();
		
		(...)
				
                 // Get content 
		if (method_exists($this, $params['mode'].'Action'))
		{
			$this->view->tab_content= call_user_func_array(array($this, $params['mode'].'Action'), null);
		}
		else
		{
			$this->view->tab_content= call_user_func_array(array($this, 'aboutAction'), null);
		}
		 
	}
	
        // Tabs
	public function aboutAction()
	{
                (...)
		return $this->view->render("profile/about.phtml"); 
	}
	
	public function worksAction()
	{
                (...)
		return $this->view->render("profile/works.phtml"); 
	}
        (...)

Re: Zend Framework - complex view

Posted: Thu Feb 16, 2012 10:20 am
by josh
Yes. That will give each tab it's own URL. The call to $this->view->render() is redundant, it gets called automatically by the view renderer by default, unless you've disabled it.

Re: Zend Framework - complex view

Posted: Mon Mar 05, 2012 8:26 pm
by John Cartwright
You might be tempted to use the action stack, don't! see http://www.rmauger.co.uk/2009/03/why-th ... k-is-evil/ (which also touches on partials, which is what you are after).