コード例 #1
0
 /**
  * Handles loading and generating a cms controlled page
  *
  * @return void
  */
 public function viewPageAction()
 {
     $cmsPage = new Datasource_Cms_Pages();
     $page = $cmsPage->getByUrl($this->url);
     // Try to work out whether some sub-styling (landlords, tenants, letting-agents) needs to be applied
     $urlSplit = explode('/', $this->url);
     $pageStyling = 'corporate';
     switch ($urlSplit[0]) {
         case 'landlords':
             $pageStyling = 'landlords';
             break;
         case 'tenants':
             $pageStyling = 'tenants';
             break;
         case 'letting-agents':
             $pageStyling = 'letting-agents';
             break;
     }
     if (count($page) > 0) {
         // Valid page in the database so load it's template and pass in the meta and content data
         $content = $this->view->partial('templates/' . $page['template'] . '.phtml', array('meta' => $page['meta'], 'content' => $page['content'], 'pageStyling' => $pageStyling));
         // Replace code snippets in the content
         $snippets = new Application_Cms_PageSnippets();
         $content = $snippets->replace($content);
         $this->view->content = $content;
         $this->view->pageTitle = $page['title'];
         $this->view->description = $page['description'];
         $this->view->keywords = $page['keywords'];
     } else {
         // Throw a 404 error
         throw new Zend_Controller_Action_Exception("This page doesn't exist", 404);
     }
 }