Inserting a text string or paragraph into Zend_Form

If you want to add text after element in form just use description of form element.

textElement = new Zend_Form_Element('someElement'); 
$textElement->setDescription('TEXT'); 

or in the form file:

        $this->addElement(
            'text',
            'some element',
            array(
                'label'         => 'Some element:',
                'description'   => 'TEXT',
            )
        );

If you are wanting something more complex you must define your own decorator.

Posted in Php, Zend Framework at September 27th, 2012. No Comments.

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.

Zend Framework get domain name

There is an easy way to get domain name with Zend Framework – use following code in your view files.

echo $this->serverUrl();
Posted in Zend Framework at June 10th, 2011. No Comments.