Storing Scrapbook Content To A Variable

Permalink 1 user found helpful
Hello!

I have the following code to display the data contained in a scrapbook page and it works great:

$block = Block::getByName('TestMessage');   
if( $block && $block->bID ) {  
$block->display();   
}


But what if I don't want to actually display the scrapbook data, but rather store the data in a variable for use later on (like sending off an e-mail, etc.). Is it possible to assign all of the html stored in a scrapbook to a PHP variable?

Thanks!

 
jordanlev replied on at Permalink Reply
jordanlev
Use php's output buffering feature, like so:
$block = Block::getByName('TestMessage');   
if( $block && $block->bID ) {  
    ob_start();
    $block->display();
    $myContent = ob_get_contents();
    ob_end_clean();
}
echo $myContent;