Welcome Guest, Not a member yet? Register   Sign In
Best practice for meta data/css/js etc
#1

[eluser]AJR[/eluser]
Hi all,

Fairly new to CI and after working with it a while i've been doing the following to load various css/js files into my header view from within the controllers. I'm also using this method for meta keywords, page titles etc:

Code:
$this->header = array(
    'page'          => strtolower(get_class($this)),
    'title'         => 'Page title',
    'keywords'      => 'key, words, keywords',
    'description'   => 'A lovely description',
    'h1'            => 'Page heading',
    'css'           => array('javascript.js',
                             'another.js'),
    'js'            => array('common.css')
);

$this->load->view('templates/header', $this->header);
$this->load->view('some/page', $this->data);
$this->load->view('templates/footer');

My header view would then load the relevent js and css files and insert the meta data into the <head> tags.

While this seems like the obvious way to do things, I don't like the idea of having whats effectively content in my controllers. It also sometimes gets repeated and makes my controllers a bit messy.

How do you all manage this? There must be a better way to do this? Language files? Config files?

Thanks for the advice.


Messages In This Thread
Best practice for meta data/css/js etc - by El Forum - 09-01-2010, 04:01 AM
Best practice for meta data/css/js etc - by El Forum - 09-01-2010, 06:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB