getContent() public method

Fetch the parsed content from this template.
public getContent ( string $template ) : string
$template string The location of the template file, used to display this template.
return string The actual parsed content after executing this template.
Example #1
0
 /**
  * Display, this wil output the template to the browser
  * If no template is specified we build the path form the current module and action
  *
  * @param string $template The template to use, if not provided it will be based on the action.
  */
 public function display($template = null)
 {
     // parse header
     $this->header->parse();
     /*
      * If no template is specified, we have to build the path ourself. The default template is
      * based on the name of the current action
      */
     if ($template === null) {
         $template = '/' . $this->getModule() . '/Layout/Templates/' . $this->URL->getAction() . '.html.twig';
     }
     $this->content = $this->tpl->getContent($template);
 }
Example #2
0
 /**
  * Returns the content from a given template
  *
  * @param  string $template  The template to use.
  * @param  array  $variables The variables to assign.
  *
  * @return string
  */
 private function getTemplateContent($template, $variables = null)
 {
     // with the strpos we check if it is a frontend template, in that case we use the frontend template to prevent
     // errors that the template could not be found. This way we don't have a backwards compatibility break.
     if (APPLICATION !== 'Backend' || strpos($template, FRONTEND_CORE_PATH) !== false) {
         return Model::get('templating')->render($template, $variables);
     }
     $tpl = new BackendTemplate(false);
     // variables were set
     if (!empty($variables)) {
         $tpl->assign($variables);
     }
     // grab the content
     return $tpl->getContent($template);
 }