21/06/2012 2:28pm

PHP | Problem - shortcode replacer


<?php

class ImgBlock extends Page {
public static $db = array(
'imgTooltip' => 'Boolean'
);

public static $has_one = array(
'imgLeft' => 'Image',
'imgRight' => 'Image'
);

static $defaults = array(
'Content' => '$ImgBlock'
);

public function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.ImgBlock", new ImageField('imgLeft', 'Afbeelding Links'));
$fields->addFieldToTab("Root.Content.ImgBlock", new ImageField('imgRight', 'Afbeelding Rechts'));
$fields-addFieldToTab("Root.Content.ImgBlock", new CheckboxField('imgTooltip', 'Laat tooltip zien'));

return $fields;
}

}
class ImgBlock_Controller extends Page_Controller {

function Content() {
return str_replace ('$ImgBlock',$this->CurrentPage()->imgRight()->forTemplate(), $this->Content);
}

}

Using this code $imgBlock will only return the first images (imgRight) into the view..
Though I want both images to be returned in the view, preferable using some kind of template


Post Comment