1 <?php
2
3 4 5 6 7 8 9 10 11 12 13 14
15 class rex_var_category extends rex_var
16 {
17 18 19
20 protected function getOutput()
21 {
22 $field = $this->getParsedArg('field');
23 if (!$field) {
24 return false;
25 }
26
27 $category_id = $this->getParsedArg('id', '$this->getValue(\'category_id\')');
28 $clang = $this->getParsedArg('clang', 'null');
29
30 return self::class . '::getCategoryValue(' . $category_id . ', ' . $field . ', ' . $clang . ')';
31 }
32
33 public static function getCategoryValue($id, $field, $clang = null)
34 {
35 if ($clang === null) {
36 $clang = rex_clang::getCurrentId();
37 }
38 $cat = rex_category::get($id, $clang);
39 if ($cat) {
40 return rex_escape($cat->getValue($field));
41 }
42 }
43 }
44