Jump to content

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. :-/

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.