Order of items included with addHeaderItem

Permalink
I'm using addHeaderItem quite often in the meanwhile. It's really great to have this method!

Unfortunately I couldn't find a way to change the order of the includes.

I've got a js that requires jquery and therefore must be called after jquery has been included.

I could do some dynamic js include but that's really nasty.

I can also include jquery on my own:
$v->addHeaderItem($html->javascript('jquery1.2.6.js'));


This works fine as addHeaderItem includes items only once. But as soon as the c5 core updates jquery to 1.3.1 my block won't be working anymore..

Did I miss something?

Remo
 
ScottC replied on at Permalink Reply
ScottC
I am not sure if this is a block or a pagetype include, below is a block: You didn't specify.

I use the code from the controller for a block instantiated(probably spelled that wrong) header include:
//load event
$this->addHeaderItem($this->smartWrapper($value,$path));


The controller will append your javascript added at the end of the array for headeritems and it will print or echo out right where you want it, at the end of your javascript block in the head of the page.


The smartWrapper function i wrote looks to see if I am adding css or javascript then inserts the value of the name of the file within a wrapper that adds the <script> or <css> tags and returns the string, the $path I am building by:
$blockPath = BASE_URL . '/' . DIRNAME_BLOCKS . '/' . $this->directoryName() . '/tools/';


Why do i do it this way? Because I don't have to add javascript in the js folder in addition to uploading a block. The helper is very nice, saves a bit of work, but I just use something I wrote since I have a fringe case in the way I want the js to load and where I put it. Weird i know :)

for a page type/view: This should work:

$v->addHeaderItem($html->javascript('mailme8x10.js','CONTROLLER'));

If you dig into the function itself which resides in view in the concrete5.2 rc2 code, the addheaderitem has a second parameter for namespace, which defaults to view so a n00b doesn't break something.

Pass it 'CONTROLLER' instead of the default 'VIEW' and it is added to the end of the controller array which is basically loaded last, view array is added/printed/whatever to the header then the controller array is loaded/added/printed.

*highfive*

-Scott
Remo replied on at Permalink Reply
Remo
thanks man!

*highten"

Remo
powermick replied on at Permalink Reply
powermick
Following the discussion by:
http://www.concrete5.org/index.php?cID=6089...

The preceding discussion is the:
http://www.concrete5.org/index.php?cID=2465...