hi there
i've made a simple gallery and now i wanna be able to insert it per variable in the content field. like in this recipe:
http://doc.silverstripe.org/doku.php?id=recipes:customising-content-in-your-templates&s=paypal
return a string for a variable works but returning the galleryitems just prints "ComponentSet".
update:
it works now. with the foreach loop i can access the items.
class GalleryPage extends Page {
static $db = array(
);
static $has_one = array(
);
static $has_many = array(
'GalleryItems' => 'GalleryItem'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new ComplexTableField(
$this,
'GalleryItems',
'GalleryItem',
array(
'Thumbnail' => 'Thumbnail',
'Beschreibung' => 'Beschreibung',
),
'getCMSFields_forPopup',
'PageID = '.$this->ID
);
$fields->addFieldToTab("Root.Content.Galerie",$manager);
return $fields;
}
static $defaults = array(
'Content' => '$GalleryPage'
);
}
class GalleryPage_Controller extends Page_Controller {
public function init() {
parent::init();
Requirements::block('jsparty/prototype.js');
}
function Content() {
$content = str_replace('$Visiogallery', $this->BB(), $this->Content);
return $content;
}
function BB() {
$output = "";
$output = '<ul class="gallery">';
$items = DataObject::get("GalleryItem");
foreach ($items as $item) {
$output .= '<a rel="b_group" href="' . $item->Bild()->Big()->URL . '" title="' . $item->Beschreibung . '"><img alt="' . $item->Beschreibung . '" src="' . $item->Bild()->Small()->URL . '" /></a>';
$output .= '<p>' . $item->Beschreibung . '</p>';
}
$output .= '</ul>';
return $output;
}
}