Welcome Guest, Not a member yet? Register   Sign In
Acessing & modifying config items from library
#1

[eluser]AlexDSX[/eluser]
Hi everyone, I've set up my config file to contain all my main CSS stylesheets and this works well, however each controller now needs to set an additional stylesheet. Here's what I have so far:

config.php (config file):
Code:
//CSS list
$config['template']['css'] = array(
"main" => "main",
"grid" => "grid",
"elements" => "elements",
"features" => "features",
);

main.php (view)
Code:
<?php foreach ($template['css'] as $stylesheet): ?>
<link href='/css/<?php echo $stylesheet; ?>.css' rel='stylesheet' type='text/css' />
<?php endforeach; ?>

I have a template library which sets the view for a page, I would build on this library to create a new function that will take my arguments and add it to my CSS array.

Desired solution:
Code:
$this->template->css('index', 'root/css/index');

Thanks for having a look and please help me out. Smile
#2

[eluser]Aken[/eluser]
One stylesheet for your website is the best solution, really. I'd recommend trying to work that way instead of a backend solution.
#3

[eluser]AlexDSX[/eluser]
The only issue with that is I still need to know how to access & modify config items from libraries for other features.
#4

[eluser]Aken[/eluser]
http://ellislab.com/codeigniter/user-gui...onfig.html
#5

[eluser]AlexDSX[/eluser]
Got my solution. Smile

Code:
public function css($name = '', $path = '')
  {
   $this->CI =& get_instance();
   $template = $this->CI->config->item('template');
   $template['css'][$name] = $path;
   $this->CI->config->set_item('template', $template);
  }

It needs work but it's an example if anyone else has the same question. Smile




Theme © iAndrew 2016 - Forum software by © MyBB