addHeaderItem not adding header item
Permalink
In a block, I have:
I've cleared the cache in Concrete, killed the browser cache, and I can't seem to get the css file to be added to the page. Any ideas?
public function view() { $categories = Category::all(); $this->set("categories", $categories); $html = Loader::helper('html'); $this->addHeaderItem($html->css('my.css', 'my_block')); }
I've cleared the cache in Concrete, killed the browser cache, and I can't seem to get the css file to be added to the page. Any ideas?
Very weird. I moved the css addHeader stuff to the on_page_view() method in the controller and now it loads. It's weird because I have another block that I created a while back (same site, it was just installed before I upgraded to 5.6.1.2) that had virtually the same code (the css was loaded in the view() method) and it works fine. ???
is your block in a stack or something?
No, it's just in the main page area.
Well according to C5 core team about on_page_view:
[quote]This function is automatically run when the block is viewed from within a page. That makes it useful when with $controller->addHeaderItem(). This is the only way to inject items into the page's header from within a block.[/quote]
So IN THEORY, view() should not do the trick
If you want to know more go there:
http://www.concrete5.org/documentation/developers/blocks/mvc-approa...
[quote]This function is automatically run when the block is viewed from within a page. That makes it useful when with $controller->addHeaderItem(). This is the only way to inject items into the page's header from within a block.[/quote]
So IN THEORY, view() should not do the trick
If you want to know more go there:
http://www.concrete5.org/documentation/developers/blocks/mvc-approa...
updated link since 5.7 came on the scene...
http://www.concrete5.org/documentation/developers/5.6/blocks/mvc-ap...
http://www.concrete5.org/documentation/developers/5.6/blocks/mvc-ap...