Jump to content

2 ways of performing task, 1 works and the other won't?


MasterACE14

Recommended Posts

Good Day Developers,

 

I've developed a template class which all works except for one part if done a certain way.

 

Firstly here's the relevant code:

    public function display($page,$template,$content)
    {
            require_once( $this->hdr );
            $template = self::gettemplate($page); // this way doesn't work
           # require_once(APPPATH.$_SESSION['cgs'].PATH_TEMPLATES . $page . '.php'); // this way does work
            echo self::parsetemplate($template,$content);
            require_once( $this->ftr );
    }

    private function gettemplate($page) { // get the template
        $filename = APPPATH.$_SESSION['cgs'].PATH_TEMPLATES . $page . '.php';
            if(file_exists($filename))
            {
                require_once($filename);
            } else {
                die("Error: No Template Specified.");
            }
        return;
    }

 

As you can see by the two comments in the first method. If I try and include that file using my second method( gettemplate() ) nothing is included, nor do I get a error. However if I just use require_once() on it's own and feed in the filepath it does work and includes the template?

 

I'm at a total loss as to why my gettemplate() method isn't working?

 

Any help is appreciated, Thanks.

 

Regards, Ace

    public function display($page,$template,$content)
    {
            require_once( $this->hdr );
            $template = $this->gettemplate($page);
           # require_once(APPPATH.$_SESSION['cgs'].PATH_TEMPLATES . $page . '.php');
            echo $this->parsetemplate($template,$content);
            require_once( $this->ftr );
    }

 

still getting the same problem. :-/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.