1 <?php
2
3 4 5 6 7
8 class rex_var_template extends rex_var
9 {
10 protected function getOutput()
11 {
12 $template_id = $this->getParsedArg('id', 0, true);
13
14 if ($template_id > 0) {
15 return self::class . '::getTemplateOutput(require ' . self::class . '::getTemplateStream(' . $template_id . ', $this))';
16 }
17
18 return false;
19 }
20
21 public static function getTemplateStream($id, rex_article_content_base $article = null)
22 {
23 ob_start();
24 $tmpl = new rex_template($id);
25 $tmpl = $tmpl->getTemplate();
26 if ($article) {
27 $tmpl = $article->replaceCommonVars($tmpl, $id);
28 }
29 return rex_stream::factory('template/' . $id, $tmpl);
30 }
31
32 public static function getTemplateOutput()
33 {
34 return ob_get_clean();
35 }
36 }
37