Jump to content

Recommended Posts

Posted

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)? 

Posted

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  ;)

Posted

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!

Posted

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

Posted

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()?

  • Like 2
Posted

@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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...