Re: Designer Contentで作成したブロックをページリストテンプレート内で表示したいです

2015年4月26日 at 0:34

contiさん

失礼しました。

get_image_object は、Designer Contetntで作成した、contollerに定義される、
private functionですね。
(相変わらず、コードの動作未検証ですが、get_image_objectのロジックを持ってきてみました)

// get instance of the block
if (is_object($blocks[0])) {
$bObj = $blocks[0]->getInstance();
// print property of the block (Designer Content style)
echo $bObj->field_1_textbox_text;


// set field_2_image from field_2_image_fID
if (!empty($bObj->field_2_image_fID)) {
$file = File::getByID($bObj->field_2_image_fID);
$ih = Loader::helper('image');

// set for width and hight attribute for image tag
$width = 200;
$width = 400;
$image = $ih->getThumbnail($file, $width, $height, true);

$bObj->set('field_2_image', $image);
}
if (!empty($field_2_image)) { ?>
<img src="<?php echo $field_2_image->src; ?>" width="<?php echo $field_2_image->width; ?>" height="<?php echo $field_2_image->height; ?>" />
<?php
}
}

Re: Designer Contentで作成したブロックをページリストテンプレート内で表示したいです

2015年4月26日 at 0:59
自分で提示しておいて、恥ずかしいですが、ちょっとコードが汚いですね。

折角、imageヘルパーを使っているので、outputThumbnailでimgタグを出力してあげた方が、
concrete5っぽくてスマートに成ります。