pwFoo Posted May 29, 2014 Share Posted May 29, 2014 I had some problems with templateFile class as template system inside a module. Tried it that way: $tpl->filename = $feu->getTpl('profile'); Works fine at PW template files, but doesn't work inside a module/ class. Get it working with setFilename in the end... $tpl->setFilename($this->getTpl('profile')); So I think setFilename should be the way to do it (right)? Link to comment Share on other sites More sharing options...
WillyC Posted June 1, 2014 Share Posted June 1, 2014 wha is. getTpl() ? mabe u need .provision full path ? wire( 'config' )->paths->templates 2 Link to comment Share on other sites More sharing options...
pwFoo Posted June 1, 2014 Author Share Posted June 1, 2014 getTpl() is a method which returns the template with full path Works with setFilename() but not with filename =. So I'll use setFilename() in the future Link to comment Share on other sites More sharing options...
adrian Posted June 2, 2014 Share Posted June 2, 2014 I'm with WillyC - I can't find getTpl() in the source code anywhere. Can you point us to the file/line on github where this method is defined. I am curious! Link to comment Share on other sites More sharing options...
pwFoo Posted June 2, 2014 Author Share Posted June 2, 2014 Hello adrian, You won't found my custom module function at github It returns the template file with full(!) path and extension. If exists from the template subdir <module> as user custom template. Else from site module directory -> subdir "views" as module default template. Path and file returned by getTpl() is double checked and works fine. If I set the template with filename within a template file it works fine. Done inside my module it doesn't set the protected class var filename. With setFilename() the class var set correct and it works. I verified it with var_dump. So I'll use setFilename() in the future Send from my mobile Link to comment Share on other sites More sharing options...
adrian Posted June 2, 2014 Share Posted June 2, 2014 Ok, thanks for the explanation - it all makes sense now I don't know what your getTpl() method actually does, but this will also return the template file's full path: echo $page->template->filename; Maybe you are already using this as part of getTpl()? 2 Link to comment Share on other sites More sharing options...
pwFoo Posted June 2, 2014 Author Share Posted June 2, 2014 @adrian My bad... code missed at first post because I modified it. Found the solution after write the post and modified it (removed to much code examples *g*) Here is my getTpl() function. protected function getTpl($tpl) { $defTpl = $this->config->paths->FrontendUsers . "/views/{$tpl}.tpl.php"; $custTpl = $this->config->paths->templates . "FrontendUsers/{$tpl}.tpl.php"; if (file_exists($custTpl)) { return $custTpl; } return $defTpl; } Thank You to help me to clearify this question, adrian and WillyC As I posted I use setFilename() to go around the problem with ->filename =. I wondered because much examples use ->filename = xyz to set template file instead of the setFilename() function, but setFilename() seems to be more "secure" to use (and get the expected result? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now