diff --git a/FieldtypePageTableExtended.module b/FieldtypePageTableExtended.module old mode 100644 new mode 100755 index 0ba8a26..200a1b7 --- a/FieldtypePageTableExtended.module +++ b/FieldtypePageTableExtended.module @@ -1,4 +1,5 @@ -pathToTemplates); if($this->renderLayout) { + $files = $this->wire('files'); $pagesToRender = $this->attr('value'); // pages $layout = ""; //get the right language label - $lang = wire('user')->language; $label = 'label'; - if (wire('user')->language->title != 'default'){ - $label = "label{$lang}"; + if ($this->wire('modules')->isInstalled('LanguageSupport') && $this->wire('user')->language->name != 'default'){ + $label = "label{$this->wire('user')->language}"; } // $this->wire("config")->paths->templates .= "views/bocks/"; // echo $this->wire("config")->paths->templates; @@ -54,12 +54,13 @@ class InputfieldPageTableExtended extends InputfieldPageTable { $layoutTitle = $p->template->$label ? $p->template->$label : $p->template->name; $ext = "." . $this->config->templateExtension; $template_name = $p->template->altFilename ? basename($p->template->altFilename, $ext) : $p->template->name; - $templateFilename = $this->config->paths->templates . $this->pathToTemplates . $template_name . $ext; + if(is_dir($this->pathToTemplates)) $templateFilename = $this->config->paths->templates . $this->pathToTemplates . $template_name . $ext; + else $templateFilename = $this->pathToTemplates; + if(preg_match('/\{(.*?)\}/', $templateFilename, $_match) && $this->config->paths->{$_match[1]}) { + $templateFilename = $this->config->paths->{$_match[1]} . str_replace($_match[0], '', $this->pathToTemplates); + } + $parsedTemplate = $files->render($templateFilename, array('page' => $p, 'isAdmin' => 1, 'pageTableExtended' => true)); - $parsedTemplate = new TemplateFile($templateFilename); - $parsedTemplate->set("page", $p); - $parsedTemplate->set("isAdmin", 1); - $parsedTemplate->options = array('pageTableExtended' => true); $p->of(true); $iconClass = "fa-angle-down"; @@ -82,7 +83,7 @@ class InputfieldPageTableExtended extends InputfieldPageTable { '.$layoutTitle.' -