php - How do I add a page to this zend project -


so i've been assigned project uses zend framework 1.12. i'm trying add page project seem missing somewhere. directory structure bit different example zend project have seen (no bootstrap dir).

-application

---controllers

------modules

---------------nopage

------------------------ indexcontroller.php

---model

---- bunch of db files

---views

----templates (smarty tpl files)

---------------nopage

------------------------ nopage.tpl

---backend

----router.php

here code router.php

$controller -> addcontrollerdirectory(root . 'application/controller/nopage', 'nopage'); $router = $controller -> getrouter();  $nopage = new zend_controller_router_route_regex( 'nopage.html', array('module' => 'nopage', 'controller' => 'index', 'action' => 'index') );  $router -> addroute('nopage', $nopage); 

here indexcontroller code nopage indexcontroller.php

<?php  /** zend_controller_action */ zend_loader::loadclass('system_controller_action');   class nopage_indexcontroller extends system_controller_action  {     public function indexaction() {              $this -> smarty -> assign('pagebody', 'nopage/404.tpl');             $this -> smarty -> assign('title', 'petidme - 404');             $this -> smarty -> display('layouts/main.tpl');     }  } 

and error:

invalid controller specified (index)

my code seems follow same structure , other routes do, have searched , searched no avail on this. knowledgeable , generous folks here @ have ideas here? if need more information glad provide it. in advance insight this.

edit code router

$controller -> addcontrollerdirectory(root . 'application/controllers/lostandfound',      'lostandfound');  $controller -> addcontrollerdirectory(root . 'application/controllers/search', 'search');  $controller -> addcontrollerdirectory(root . 'application/controllers/orderstatus', 'orderstatus');  $controller -> addcontrollerdirectory(root . 'application/controllers/myaccount', 'myaccount');   $controller -> addcontrollerdirectory(root . 'application/controllers/giftcard', 'giftcard');  $controller -> addcontrollerdirectory(root . 'application/controller/nopage', 'nopage');    $router = $controller -> getrouter();   $nopage = new zend_controller_router_route( 'nopage.html', array('module' => 'nopage', 'controller' => 'index', 'action' => 'index') );  $router -> addroute('nopage', $nopage); //****************** gift card ************************************************************  $giftcard = new zend_controller_router_route_regex( 'giftcard.html', array('module' => 'giftcard', 'controller' => 'index', 'action' => 'index') ); $router -> addroute('giftcard', $giftcard);  $giftcardspages = new zend_controller_router_route_regex( 'admin/gift/page/(\d*)', array('module'=>'admin', 'controller'=>'gift', 'action'=>'index'), array(1  =>'page') ); $router -> addroute('giftcardspages', $giftcardspages);  //****************** search *************************************************************** $topsearchserult = new zend_controller_router_route_regex( 'topsearchserult.html', array('module'=>'search', 'controller'=>'index', 'action'=>'search'), array(1  =>'page') ); $router -> addroute('topsearchserult', $topsearchserult);  //****************** account *********************************************************  $myaccount = new zend_controller_router_route_regex( 'myaccount.html', array('module' => 'myaccount', 'controller' => 'index', 'action' => 'index') ); $router -> addroute('myaccount', $myaccount); 

and other indexcontroller pages:

zend_loader::loadclass('system_controller_action');  class news_indexcontroller extends system_controller_action {  public function init() {     parent::init(); }  public function viewaction() {     $new = $this -> news -> getnewbyid($this->_getparam('new_id'));     $this->smarty->assign('new', $new);     $this->smarty->assign('title', $new['new_title']);     $this->smarty->assign('pagebody', 'news/show_item.tpl');     $this->smarty->display('layouts/main.tpl'); }  public function indexaction() {      $page = $this->_hasparam('page')?((int)$this->_getparam('page')-1):0;      $items = $this->news->getnewsforpage($page);      $this->smarty->assign('items', $items);     $this->smarty->assign('title', 'news items');     $this->smarty->assign('page_num', $page+1);     $this->smarty->assign('page_count', $this->news->getpagescount());     $this->smarty->assign('pagebody', 'news/index.tpl');     $this->smarty->display('layouts/main.tpl'); } 

and another

zend_loader::loadclass('system_controller_action'); include_once root . 'application/models/giftcardsdb.php'; class giftcard_indexcontroller extends system_controller_action  { private $giftcard;  public function init() {     $this->giftcard = new giftcarddb();     parent::init(); }  public function indexaction() {     if($this->_hasparam('product_id')){         $this -> smarty -> assign('giftcard_text', $this -> content ->     getpagebylink('giftcard.html'));         $this -> smarty -> assign('giftcard_agreement_text', $this -> content -> getpagebylink('giftcard_agreement.html'));         $this -> smarty -> assign('pagebody', 'giftcard/index.tpl');         $this -> smarty -> assign('product_id', $this->_getparam('product_id'));         $this -> smarty -> assign('title', 'pet id me - gift card');         $this -> smarty -> display('layouts/main.tpl');     } else {         $this->_redirect("/");     }     } 

you add zend framework page steps given

1.zend mvc pattern

2.create view file name , controller file name same name

example : view->save.phtml controller:saveaction

3.you include database connection implement controller (or) call db method refer follow link http://www.phpeveryday.com/articles/zend-framework-basic-tutorial-p840.html


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -