Zend Framework - complex view

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
michalowskiego
Forum Newbie
Posts: 1
Joined: Fri Nov 25, 2011 3:13 am

Zend Framework - complex view

Post 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"); 
	}
        (...)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Zend Framework - complex view

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Zend Framework - complex view

Post 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).
Post Reply