How do I add CSS or JS includes from blocks

Permalink
How do I add to the header from a block?

 
beeman89045 replied on at Permalink Reply
describe further what you are trying to accomplish ... I think that would help.
aaron replied on at Permalink Reply
<head>How do I get code here from wihtin a block</head>
beeman89045 replied on at Permalink Reply
tag is part of the template. Not the block. So, I would probably recommend editing the template you are using and insert the HEAD CSS/JS there.
jelthure replied on at Permalink Reply
jelthure
use:
$this->addHeaderItem('<script src="location/of/your.js" type="text/javascript"></script>','CONTROLLER');


This is the method i use from within my blocks construct function, if you do not have a construct function then here's what it looks like:
function __construct($obj = null) {
      parent::__construct($obj);
}


hope this helps!
beeman89045 replied on at Permalink Reply
new everyday. I didn't know there was such a function. Good to know.

Of course, that is assuming you are writing your own block (or extending a core block ... which would also work).
scoop replied on at Permalink Reply
I'm trying to do the same thing with a nicedit block I'm busy with :

public function getBlockPath() {
      return t("/concrete/packages/nicedit/blocks/nicedit");
   }
   public function __construct($obj = null) {      
      parent::__construct($obj);
         $niceditjs = ($this->getBlockPath() . ('/nicEdit.js'));
         $html = Loader::helper('html');
         $this->addHeaderItem($html->javascript($niceditjs));  
   }

In controller.php does it but is there no way to include the js file at the top of the head tag?
According to :

http://docs.jquery.com/Using_jQuery_with_Other_Libraries#Including_...

There is no need for overriding the $-function by calling "jQuery.noConflict()" when no jquery js files are included before any jquery js files in the head.

Adding js files that are not used with jquery to the bottom of the head tag in concrete5 by default seems very wrong because it's very jquery centric.

Also I think there is a better way in the api to do the :

public function getBlockPath() {
      return t("/concrete/packages/nicedit/blocks/nicedit");
   }

bit, any thoughts/suggestions?
powermick replied on at Permalink Reply
powermick
Following the discussion by:
http://www.concrete5.org/index.php?cID=11369...

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