In the view file,
echo $this->partial('index/partial.phtml', 'module')
You have to create the partial.phtml in views/helpers/index folder, where index is the controller name. You can specify the module as the second parameter.
Create Form for Modules
While creating forms for the modules, we can do it by creating a folder with Module name in the /forms folder. While you name the class you have to use Form_Module_FileName and you have to same in the controller
Ex:
In /application/forms/Admin
class Form_Admin_Register extends Zend_Form{
}
In the controller you have to initiate form by using
$form = new Form_Admin_Register();
Ex:
In /application/forms/Admin
class Form_Admin_Register extends Zend_Form{
}
In the controller you have to initiate form by using
$form = new Form_Admin_Register();
How to create custorm profile url using Zend Framework
In the boortrap file create and init function
public function _initRoute()
{
$frontController = Zend_Controller_Front::getInstance();
$route = new Zend_Controller_Router_Route(
'profile/*',array(
'controller' => 'profile',
'module' => 'default',
'action' => 'index',
'name' => ”));
$frontController->getRouter()->addRoute('profile',$route);
}
Ex: http://cochinhub.com/profile/john.steve
public function _initRoute()
{
$frontController = Zend_Controller_Front::getInstance();
$route = new Zend_Controller_Router_Route(
'profile/*',array(
'controller' => 'profile',
'module' => 'default',
'action' => 'index',
'name' => ”));
$frontController->getRouter()->addRoute('profile',$route);
}
Ex: http://cochinhub.com/profile/john.steve
How to use Zend Framework Database functions for other application
- Include Zend library using set_include_path or .htaccess
- include 'Zend/Db/Table.php';
- $db = Zend_Db::factory('Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'userName',
'password' => 'password',
'dbname' => 'dbName',
));
- include 'Zend/Db/Table.php';
- $db = Zend_Db::factory('Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'userName',
'password' => 'password',
'dbname' => 'dbName',
));
How to redirect with parameters in Zend Framework
$this->_helper->_redirector('action','controller','module',array('param1'=>'value1'));
How to get the table column names using Database functions
$result = $this->db->query($sql_query);
$result->setFetchMode(Zend_Db::FETCH_NUM);
$metaData = $this->db->describeTable('tableName');
$columnNames = array_keys($metaData);
$result->setFetchMode(Zend_Db::FETCH_NUM);
$metaData = $this->db->describeTable('tableName');
$columnNames = array_keys($metaData);
Zend Framework : Difference ways to redirect from controller
Zend Framework 1.8 Web Application Development
1. $this->_helper->redirector('index','profile');
2. $url = $this->_helper->url('index','profile','',array('smsg'=>'moved'));
$this->_helper->redirector->goToUrl($url);
3. $this->_forward('index','profile');
PHP Zend Studio 5 - Instructor-based Video Training
1. $this->_helper->redirector('index','profile');
2. $url = $this->_helper->url('index','profile','',array('smsg'=>'moved'));
$this->_helper->redirector->goToUrl($url);
3. $this->_forward('index','profile');
PHP Zend Studio 5 - Instructor-based Video Training
Subscribe to:
Posts (Atom)