Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ss2.4 ImageField problem


Go to End


2 Posts   1451 Views

Avatar
slavelabourer

Community Member, 26 Posts

17 June 2010 at 3:21pm

So I need dynamic image slider for a homepage. Pretty standard so i copy pasted it from a 2.3 site done 6 months ago. This code works on 2.3 but 2.4 the fields don't appear in the cms, any suggestions? thanks guys.

<?php
/**
* Defines the HomePage page type
*/

class HomePage extends Page {
static $db = array(

);
static $has_one = array(
'AdSpace1' => 'Image',
'AdSpace2' => 'Image',
'AdSpace3' => 'Image'
);

}

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace1', "Ad Space 1"), 'Content');
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace2', "Ad Space 2"), 'Content');
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace3', "Ad Space 3"), 'Content');
return $fields;
}

class HomePage_Controller extends Page_Controller {

function LatestNews($num=5) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}

public function init() {
parent::init();

Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");

Requirements::javascript('mysite/javascript/jquery.js'); //jquery library
Requirements::javascript('mysite/javascript/jquery-cycle.js'); // plugin
Requirements::javascript('mysite/javascript/myCustomCycle.jquery.js'); // controller

Requirements::block('jsparty/jquery/jquery.js');
Requirements::block('jsparty/jquery/jquery_improvements.js');
Requirements::block('jsparty/prototype.js');
Requirements::block('jsparty/prototype_improvements.js');
Requirements::block('jsparty/prototype15.js');

// Requirements::javascript('mysite/javascript/supersleight.js'); // transparency hack for ie
// Requirements::javascript('mysite/javascript/supersleight-min.js'); // transparency hack for ie
}
}
?>

Avatar
slavelabourer

Community Member, 26 Posts

17 June 2010 at 3:54pm

So I see that I left a } out in the last post, fixed but still hasnt fixed my problem now the grey area where the form should be appears but no form

static $has_one = array(
'AdSpace1' => 'Image',
'AdSpace2' => 'Image',
'AdSpace3' => 'Image'
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace1', "Ad Space 1"));
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace2', "Ad Space 2"));
$fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace3', "Ad Space 3"));
return $fields;
}
}