5095 Posts in 1518 Topics by 1114 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1034 Views |
-
Can't add images to the CMS

13 February 2009 at 5:44am
Greetings folks,
I'm working on my first SilverStripe powered site. I am building a layout that is going to have several different tabs in the CMS, each for a different type of data. One of these tabs, "Resellers", should allow for the user to upload 4 reseller logos, to be displayed at the bottom of the page.
I am using this code inside my HomePage.php file:
class HomePage extends Page {
'Reseller1' => 'Image',
'Reseller2' => 'Image',
'Reseller3' => 'Image',
'Reseller4' => 'Image'
}function getCMSFields() {
$fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller1', 'Reseller Logo 1'));
$fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller2', 'Reseller Logo 2'));
$fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller3', 'Reseller Logo 3'));
$fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller4', 'Reseller Logo 4'));
}And when I run my /db/build/?flush=1 I get this error message:
FATAL ERROR: DataObject::__construct passed The value 'Reseller1'. It's supposed to be passed an array, taken straight from the database. Perhaps you should use DataObject::get_one instead?
At line 83 in C:\wamp\www\valtus-ss\sapphire\core\model\DataObject.phpCan anyone help me solve this issue?
-
Re: Can't add images to the CMS

13 February 2009 at 10:15pm
You need to link your images to your class by defining a relationship.
e.g.
static $has_one = array(
'Thumbnail' => 'Image',
); -
Re: Can't add images to the CMS

13 February 2009 at 11:59pm
Hi Dan
I'd recommend going through tutorials 1 and 2 to see how these things work.
http://doc.silverstripe.org/doku.php?id=tutorial:1-building-a-basic-site
http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site
| 1034 Views | ||
|
Page:
1
|
Go to Top |


