Pulling a block from another page

Permalink
Hello!

I've got a crazy question. I'm trying to pull an image block from another page to use with the Page List. I keep getting this

error:Warning: file_exists() expects parameter 1 to be string, array given in /home/potatoes/public_html/concrete/helpers/image.php on line 203

Warning: explode() expects parameter 2 to be string, array given in /home/potatoes/public_html/concrete/helpers/file.php on line 265

This is the code I"m using.

$img_block = $page->getBlocks("RecipeImage");
$thumb = $ih->getThumbnail($img_block, 150, 999);


Simple right? I know I'm just missing a line in there. I know there is a way to do it using the Page Attributes buuut I'd rather not take that route if I don't have to. Any help would be wooonderful! :D

rainmaker
 
rainmaker replied on at Permalink Reply
rainmaker
Awww...no one? :(
mesuva replied on at Permalink Best Answer Reply
mesuva
The problem I can see with this is that getThumbnail is expecting a File object, while $img_block is actually an array of block object.

I've not done it this way before, but I think you would need to do something like:
$blocks = $page->getBlocks("RecipeImage");  // get all blocks in area
$img_block = array_shift($blocks);  // get the first block
if (!is_null($img_block)) {   // if the first block exists 
$file = $img_block->getFileObject();  // assuming it is an image block, get the file object
$thumb = $ih->getThumbnail($file, 150, 999);
}


I'm don't think this is a good approach as there's no way to guarantee that the first block in the area is actually an image block.
rainmaker replied on at Permalink Reply
rainmaker
Hey mesuva! Ah I see. I thought there was a way to for sure grab a certain block or something. Hmm. Guess I was wrong. ^_^ Thanks!