Welcome Guest, Not a member yet? Register   Sign In
Newbie Question
#1

[eluser]musonic[/eluser]
I've only been using CodeIgniter for one day, so apologies if this is an incredibly stupid question!
I've created a view to generate an HTML header which will be used across all pages on my application. I've worked out how to store paths to CSS, Javascript files etc. along with metadata like keywords, title info etc. in the config file and then calling it in the controller using
Code:
$data[foo] = $this->config->item[foo];
before passing it to the view.
Surely there is someway that I don't have to assign all these elements into the $data array for every controller that I write. Could someone explain how best to it?
Many thanks.
#2

[eluser]jedd[/eluser]
Hi Nicholas and welcome to the CI forums.

I suspect you want to read [url="http://codeigniter.com/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]this page in the wiki[/url] - it'll point you at extending your core controller - using the MY_Controller stuff. This is also documented in the manual, but have a read of my wiki page first and see if that makes sense.

You'll get a few gains there - title info should probably only really be displayed in one view file (a partial that contains header information), config stuff can be pulled in at MY_Controller into $this->foo type variables so they're accessible everywhere else (though this defeats much of the benefit of using the Config class, I think).




Theme © iAndrew 2016 - Forum software by © MyBB