Getting not only the block data by ID but also its css
Permalink 1 user found helpful
In a view I can grab the data of any random block and display it like so:
This gives me the data and the HTML of the block but it does not add the css or javascript that comes with the block.
How can I include e.g. the CSS as well?
Thx :-)
$block = Block::getByID($bID); $block->display($view = 'view', $args = array());
This gives me the data and the HTML of the block but it does not add the css or javascript that comes with the block.
How can I include e.g. the CSS as well?
Thx :-)

Try
unfortunately render is not a method of block :-(
Well it looks like it is not yet possible to do this through the API...
http://www.concrete5.org/developers/bugs/5-4-1-1/global-scrapbook-b...
Might check out the Global stacks/blocks options.
More Info:http://www.concrete5.org/community/forums/customizing_c5/global-sta...
http://www.concrete5.org/developers/bugs/5-4-1-1/global-scrapbook-b...
Might check out the Global stacks/blocks options.
More Info:http://www.concrete5.org/community/forums/customizing_c5/global-sta...
i found this which gives me objects that contain the js and css of a block. i can then add them to the header using $this->addHeaderItem(). it seems a bit clumsy though.
ps: what annoys me massively is that I cannot use $this->addHeaderItem() inside the view() method of a controller......d'oh.
$b = Block::getByID(156); $bvt = new BlockViewTemplate($b); $headers = $bvt->getTemplateHeaderItems(); if (count($headers) > 0) { foreach($headers as $h) { $this->addHeaderItem($h); } }
ps: what annoys me massively is that I cannot use $this->addHeaderItem() inside the view() method of a controller......d'oh.
@nerdess - I ran into this today. Were you able to find any other way? I'm pulling in blocks through a helper class in my theme files but I can't pull the CSS / JavaScript associated. It's not ideal for me to add header items through a controller given the strange dynamic behavior and requirements of the site I'm working on. If I recall, I can actually have controllers for me theme template files. Is this correct? Just wondering if there were any others ways.
Thanks!
Thanks!