How to render a block from the Global Scrapbook with view.css pulled in programmatically?
Permalink
I have a Page Type listing various placeholder Areas for various types of content. One is "Add to Page Title". Another area is called "Add to Photo" and so on.
To make it easier on the client to know where to add what and to add a new page. All well and good.
But...I need to add a global block to the page automatically when the client adds a new page. Now normally I would just create a new content Area, that would show up as "Add to Content", add a block to that area through the Page Type Default, and voila! Done.
But...I don't want another area showing up to confuse the end client called "Add to Content". An Area he really is not supposed to do anything with on this particular page.
So...I got smart and decided to pull the block in from the Global Scrapbook programmatically just after the last placeholder Area that the client is supposed to add camera specs to. Like so...
Trouble is that pulling in the block this way bypasses something such that the view.css file of that block is no longer pulled in.
Is there a way for me to force the pulling in of the view.css for a Global Scrapbook block programmatically?
You know...something like...
$block->loadViewCSS();
Or some such?
I mean I know there is no such method but is there a way to do this somehow?
Or am I stuck having to have an Area called "Add to Content" show up which the client will have no use or dealings with (and which Area will allow me to add the block in question through the usual Page Type Default method)?
Any insight would be appreciated.
Thanks.
Carlos
To make it easier on the client to know where to add what and to add a new page. All well and good.
But...I need to add a global block to the page automatically when the client adds a new page. Now normally I would just create a new content Area, that would show up as "Add to Content", add a block to that area through the Page Type Default, and voila! Done.
But...I don't want another area showing up to confuse the end client called "Add to Content". An Area he really is not supposed to do anything with on this particular page.
So...I got smart and decided to pull the block in from the Global Scrapbook programmatically just after the last placeholder Area that the client is supposed to add camera specs to. Like so...
<?php $a = new Area('Camera Specs'); $a->setBlockLimit(1); $a->display($c); /* pull Paypal block in from Global Scrapbook (where it is) */ $block = Block::getByName('Paypal Shopping Cart'); $block->display(); ?>
Trouble is that pulling in the block this way bypasses something such that the view.css file of that block is no longer pulled in.
Is there a way for me to force the pulling in of the view.css for a Global Scrapbook block programmatically?
You know...something like...
$block->loadViewCSS();
Or some such?
I mean I know there is no such method but is there a way to do this somehow?
Or am I stuck having to have an Area called "Add to Content" show up which the client will have no use or dealings with (and which Area will allow me to add the block in question through the usual Page Type Default method)?
Any insight would be appreciated.
Thanks.
Carlos
I figured out that if I limit the block to 1 instance on the page that the Area will never even show up. Just the block will show up.
Which is what I was after.
So my revised code is...
When I go in the Page Type Default and paste the block in from the Global Scrapbook, the block correctly pulls in the view.css file that way and given the limit of 1 such block...the "Add to Paypal Shopping Cart" does not even show up on the page.
Sweet.
Carlos