Adding a Header Item in a Package Controller
Permalink 2 users found helpful
I am having some trouble figuring out how to do this. I have a package I am trying to finish it works but I think it could be more efficient. Anyhow, what is the best way to add javascript as a header item to all but the system pages in a non block package? I have tried several things but none work. Here is what I have so far?
Any suggestions? Thanks in advanced.
Dwayne
public function install() { $pkg = parent::install(); Loader::model('single_page'); // install pages $cp = SinglePage::add('/dashboard/ebibleicious/', $pkg); $cp->update(array('cName'=>t('eBibleicious'), 'cDescription'=>t('Instant Bible Reference'))); } function on_start() { $html = Loader::helper('html'); $pkg = Package::getByHandle('ebibleicious'); $active = $pkg->config('EBIBLEICIOUS_ACTIVE'); if($active == 'on'){ $mode = $pkg->config('EBIBLEICIOUS_MODE'); $translation = $pkg->config('EBIBLEICIOUS_TRANSLATION'); $topics = $pkg->config('EBIBLEICIOUS_TOPICS');
Viewing 15 lines of 21 lines. View entire code block.
Any suggestions? Thanks in advanced.
Dwayne
For anyone else reading this 3 years down the line, you can add header items from package controllers like so....
This will add the item to EVERY page on your site.
public function on_start() { $v = View::getInstance(); $v->addHeaderItem('<script src="/path/to/my/script.js"></script>'); }
This will add the item to EVERY page on your site.
If you run into a problem like this you need to create a class for your add-on and then hook into an event.
Like this:
Then you create you model. In mycase my model looked like this:
Now i can run the script on every page. Maybe this will help someone eventually.
Thanks to:
http://www.concrete5.org/community/forums/customizing_c5/package-in...
http://www.concrete5.org/documentation/developers/system/events/...