template::__construct PHP Method

__construct() public method

public __construct ( $template, $vars = [] )
    public function __construct($template, $vars = array())
    {
        // base path
        $base = PATH . 'themes' . DS . Config::meta('theme') . DS;
        // custom article and page templates
        if ($template == 'page' or $template == 'article') {
            if ($item = Registry::get($template)) {
                if (is_readable($base . $template . '-' . $item->slug . EXT)) {
                    $template .= '-' . $item->slug;
                } elseif (is_readable($base . $template . 's/' . $template . '-' . $item->slug . EXT)) {
                    $template .= 's/' . $template . '-' . $item->slug;
                } elseif (is_readable($base . $item->pagetype . EXT)) {
                    $template = $item->pagetype;
                    if (is_readable($base . $item->pagetype . '-' . $item->slug . EXT)) {
                        $template .= '-' . $item->slug;
                    }
                }
            }
        }
        if ($template == 'posts') {
            if ($item = Registry::get('post_category')) {
                if (is_readable($base . 'category-' . $item->slug . EXT)) {
                    $template = 'category';
                    $template .= '-' . $item->slug;
                }
            }
        }
        $this->path = $base . $template . EXT;
        $this->vars = array_merge($this->vars, $vars);
    }

Usage Example

Example #1
0
 public function __construct($view, $partial_path, $object = null, $locals = array())
 {
     list($this->path, $this->variable_name) = $this->extract_partial_name_and_path($view, $partial_path);
     parent::__construct($view, $this->path, true, $locals);
     $this->add_object_to_local_assigns($object);
     $this->initialize_counter();
     $this->prepare();
 }
All Usage Examples Of template::__construct