How to set page titles in Zend Framework

Welcome, today I will show you how to set page title on page in Zend Framework.
In Zend Framework, you can set the page title in the controller, like in the example below:

<?php
class Panel_TestsController extends Zend_Controller_Action
{
  public function testAction() {
    //  setting the page title
    $this->_helper->layout()->getView()->headTitle('View all students');
  }
}

or in the view:

/**
 * views/scripts/tests/index.phtml
 */
$this->headTitle('View all students');

And that’s all. Good luck

Posted in Php, Zend Framework at September 17th, 2011. 3 Comments.

How can I get the current module, controller and action in Zend Framework?

Today I will show you how to get current module, controller and action name in Zend Framework. In the default routing, both the module, controller and the action are always passed along with the request. And the code to retrieve them is very simple:

$moduleName = $this->getRequest()->getModuleName();
$controllerName = $this->getRequest()->getControllerName();
$actionName = $this->getRequest()->getActionName();

And that’s all. Good luck.

Posted in Php, Zend Framework at July 27th, 2011. No Comments.