EllisLab text mark
Advanced Search
     
Colin Williams Template Library and themes
Posted: 27 August 2010 12:44 PM
Joined: 2010-08-27
1 posts

I have been trying for the past couple of days to implement themes in this library, but somehow I can’t get the variables set in the config array. I made a function called “set_theme” like this:

function set_theme($theme){
$this->config->set_item('theme', $theme);
}

and a variety:

function set_theme($theme){
$this->theme = $theme;
}

but neither seem to do any different…

and then in my Public_Controller I added:
$this->template->set_theme($this->config->item(‘public_theme’));

I have been trying to change the various functions to accept the theme folder, but i cant seem to get the variable into the $template string.

I added a $template[‘use_theme’] = true to the template config so it can swith between views and themes folders and that works in the function f. ex.


function initialize($props)
  {
// Set master template
if($this->config['use_theme'] == true){
$folder = 'themes/'.$this->theme.'/';
} else {
$folder = 'views/';
}
   
   
    if (isset($props[‘template’]) && $this->_is_file($folder, $props[‘template’]))
    {

$this->master = $folder.$props['template'];

}
   
    else
    {
// Master template must exist. Throw error.
show_error('Line 188: "'.$props['template'].'" Either you have not provided a master template or the one provided does not exist in '. APPPATH .$folder.'. Remember to include the extension if other than ".php"');
}
   
    // Load our regions
    if (isset($props[‘regions’]))
    {
$this->set_regions($props['regions']);
}
   
    // Set parser and parser method
    if (isset($props[‘parser’]))
    {
$this->set_parser($props['parser']);
}
    if (isset($props[‘parser_method’]))
    {
$this->set_parser_method($props['parser_method']);
}
   
    // Set master template parser instructions
    $this->parse_template = isset($props[‘parse_template’]) ? $props[‘parse_template’] : FALSE;
  }

what am i possibly doing wrong?? I keep getting this error:

An Error Was Encountered

Line 188: “template” Either you have not provided a master template or the one provided does not exist in application/themes//. Remember to include the extension if other than “.php”

I feel like i’m on the right track, but I’m not exactly a hardcore programmer so I may be off by a mile…