rolandtoth/TemplateLatteReplace

Ignored templates and TemplateFile class

Opened this issue · 1 comments

Hi, I've had an issue with Seo Maestro module which uses the TemplateFile class to render output from a template stored in the module folder. This line:

if (in_array($templateFile->page->template->name, $ignoredTemplates)) {
checks against current page template which doesn't work in this situation. It could be changed to the below, although I am not sure if this is the best way to get the file name:

if (in_array(basename($templateFile->filename,".php"), $ignoredTemplates)) {
  return;
}
kp52 commented

The check for ignored templates in v 0.6.1 also fails when using Tracy Debugger console on a front-end page. The above solution works for me. So does reverting to the checking method used in an earlier version of TemplateLatteReplace (but keeping the array_map trimming):

`

       $ignoredTemplates = array_map('trim', explode(',', $this->ignoredTemplates));

        foreach ($ignoredTemplates as $t) {
            if (strpos($templateFile->filename, $t) !== false) {
                return;
            }
        }

`