Inject code once in a page from a block
Permalink
Hi !
I use the same custom block more the once in a view. Every block have the same css code to display so I have the same css code many times in the page.
So I have two questions :-)
1) How can I check if a block is used in another area on the page?
2) Can I inject the css code one time into the page from a block view?
Thanks,
Willy
I use the same custom block more the once in a view. Every block have the same css code to display so I have the same css code many times in the page.
So I have two questions :-)
1) How can I check if a block is used in another area on the page?
2) Can I inject the css code one time into the page from a block view?
Thanks,
Willy
http://www.concrete5.org/documentation/developers/blocks/mvc-approa...
you'd add something like this to your block controller
That adds the css code to array of items to be added to the header. Before they're inserted int the header it's run through array_unique and the css is inserted only once even if that block is rendered multiple times.