Is there any way to set the image/flash ad dimensions (width/height) for custom blocks created with Views?

Comments

gkom’s picture

Status: Active » Fixed

Just in case someone else is looking to do the same, I managed to solve this by adding two custom fields (width + height) to the ad node type and using their values in /mytheme/simpleads_flash_element.tpl.php.

This code in the template:

$width = !empty($settings['ads_width']) ? check_plain($settings['ads_width']) : $width_custom;
$height = !empty($settings['ads_height']) ? check_plain($settings['ads_height']) : $height_custom;

is replaced with the following:

$items = field_get_items('node', $ad['node'], 'field_width');
$width_custom = $items[0]['value'];
// set default if custom width isn't provided
$width_custom = !empty($width_custom) ? $width_custom : '120';

$items = field_get_items('node', $ad['node'], 'field_height');
$height_custom = $items[0]['value'];
// set default if custom height isn't provided
$height_custom = !empty($height_custom) ? $height_custom : '120';

// use block settings if available, otherwise use the ones set above
$width = !empty($settings['ads_width']) ? check_plain($settings['ads_width']) : $width_custom;
$height = !empty($settings['ads_height']) ? check_plain($settings['ads_height']) : $height_custom;

If someone has a better way please let us know.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.