Example #1
0
 /**
  * Render the page in its template and layout. Uses a Template
  * object for rendering. Determines whether to render with a
  * layout template at all, and if so, which one. Also determines
  * whether to render as a preview or as a real page.
  */
 public function render($tpl, $controller)
 {
     if ($this->layout === false || self::$bypass_layout) {
         // No layout, return the body as-is
         return $this->body;
     }
     // Set default menu and window titles if they're empty
     $this->_menu_title = !empty($this->_menu_title) ? $this->_menu_title : $this->title;
     $this->_window_title = !empty($this->_window_title) ? $this->_window_title : $this->title;
     // No layout, use default
     if ($this->layout === '') {
         $this->layout = 'default';
     }
     // Fetch the default layout setting
     if ($this->layout === 'default') {
         $this->layout = conf('General', 'default_layout');
     } elseif ($this->layout === 'admin') {
         $admin_layout = Product::admin_layout();
         $this->layout = $admin_layout ? $admin_layout : 'admin';
     }
     // Determine render method (preview or real)
     if ($this->preview) {
         $out = $tpl->render_preview($this->layout, $this);
         $res = $controller->hook('page/render', array('html' => $out));
         return $res ? $res : $out;
     }
     $out = $tpl->render($this->layout, $this);
     $res = $controller->hook('page/render', array('html' => $out));
     return $res ? $res : $out;
 }