Inherit parent class configuration Smarty

Source: Internet
Author: User


It is not possible to inherit the parent class and then rewrite its private properties. Without changing its source code, this would require the use of the two interface functions provided by Smarty.

Settemplatedir () and Setcompiledir ()

The configuration is as follows:

Class Mysmarty extends smarty{

                   publicfunction __construct () {

                            parent::__construct ();

                            $this->settemplatedir= './templates ';

                            $this->setcompiledir= './compile ';                      

                   }
         }

The source code is as follows:

Private $template _dir = Array ('./templates/');

 Private $compile _dir = './templates_c/';


Public Functionsettemplatedir ($template _dir)

    {

       $this->template_dir = Array ();

       foreach ((array) $template _dir as $k + = $v) {

           $this->template_dir[$k] = RTrim ($v, '/\\ '). DS;

       }

        $this->joined_template_dir = Join (' # ', $this->template_dir);

       return $this;

    }

Public Function Setcompiledir ($compile _dir)

    {

       $this->compile_dir = RTrim ($compile _dir, '/\\ '). DS;

       if (!isset (smarty::$_muted_directories[$this->compile_dir])) {

           smarty::$_muted_directories[$this Compile_dir] = null;

        }

 

       return $this;

    }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.