/**
  * Include another template inside the main template (called within the template file).
  * Included template inherits parent templates variables and can optionally set its own
  * which live within the scope of that included template only.
  *
  * @param string $filename Filename for template to include - uses the same file paths as the parent
  * @param array $vars Optionally pass additional variables to the template
  * @return void
  * @author Ed Eliot
  **/
 protected function inc_template($filename, $vars = array())
 {
     $template = new HaploTemplate($filename, $this->filePaths);
     $template->vars = $this->vars;
     if (count($vars)) {
         foreach ($vars as $key => $value) {
             $template->set($key, $value);
         }
     }
     echo $template->render();
 }
Exemplo n.º 2
0
 /**
  * This method is called when all types of request are received
  *
  * @return void
  * @author Ed Eliot
  **/
 protected function do_all()
 {
     $page = new HaploTemplate($this->config->get_key_or_default($this->section, 'layout', '_layout.php'));
     $page->set('section', $this->section);
     $page->set('title', $this->config->get_key_or_default($this->section, 'title'));
     $page->set('metaDesc', $this->config->get_key_or_default($this->section, 'metaDesc'));
     $page->set('metaKeywords', $this->config->get_key_or_default($this->section, 'metaKeywords'));
     $page->set('translations', $this->translations);
     $page->set('content', new HaploTemplate('page-not-found.php'));
     $page->display();
 }
Exemplo n.º 3
0
 /**
  * This method is called when all types of request are received
  *
  * @return void
  * @author Ed Eliot
  **/
 protected function do_all()
 {
     if ($template = $this->router->get_request_var('template', 'home')) {
         $template = trim($template, '/');
         $this->section = $template;
         try {
             $page = new HaploTemplate($this->config->get_key_or_default($this->section, 'layout', '_layout.php'));
             $page->set('section', $this->section);
             $page->set('title', $this->config->get_key_or_default($this->section, 'metaTitle'));
             $page->set('metaDesc', $this->config->get_key_or_default($this->section, 'metaDesc'));
             $page->set('metaKeywords', $this->config->get_key_or_default($this->section, 'metaKeywords'));
             $page->set('translations', $this->translations);
             $page->set('content', new HaploTemplate($template . '.php'));
             $page->display();
         } catch (Exception $e) {
             $this->do_404();
         }
     } else {
         throw new HaploTemplateNotFoundException('Static page template not specified in ' . $this->router->get_action() . '.');
     }
 }