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:

Archive /

Our old forums are still available as a read-only archive.

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

new image field


Go to End


5 Posts   2005 Views

Avatar
Nicolaas

Forum Moderator, 224 Posts

9 October 2007 at 2:06pm

Edited: 09/10/2007 4:18pm

Hi

I added a new image field, but I get the following error in the CMS:

Fatal error: Class 'HTTP' not found in /home/newhorizonsforwomen/sapphire/core/model/DataObject.php on line 90

I had added them as follows:

$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo1'));
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo2'));

Sometimes it works but most of the time I get the error above.

Any ideas?

Nicolaas

Avatar
Nicolaas

Forum Moderator, 224 Posts

9 October 2007 at 2:09pm

Another pageType only adds one image:

$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo1'));

For this one, I get the following error (no right-hand-side is shown at all).

Fatal error: Class 'SQLMap' not found in /home/newhorizonsforwomen/sapphire/security/Group.php on line 90

Curious....

I am using the latest version of ss

Avatar
Nicolaas

Forum Moderator, 224 Posts

9 October 2007 at 2:11pm

The complete class is as follows:

class LargeRightPanelPage extends Page {
static $db = array();
static $has_one = array();
static $icon = "...";
function getCMSFields() {
$fields = parent::getCMSFields();
//$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo1'));
$fields->addFieldToTab('Root.Content.Quotes', new TextareaField('Quote'));
$fields->addFieldToTab('Root.Content.Quotes', new TextField('Person'));
$fields->addFieldToTab('Root.Content.Quotes', new TextField('Organisation'));
return $fields;
}
}

Avatar
jam13

121 Posts

9 October 2007 at 11:41pm

Do you not have to add those fields to the database in order to be able to edit them in the CMS?

class LargeRightPanelPage extends Page {
  static $db = array(
    'Quote' => 'HTMLText',
    'Person' => 'Varchar',
    'Organisation' => 'Varchar'
  );
  static $has_one = array(
    'Photo1' => 'Image'
  ); 

HTMLText is from memory and might not be a valid data type - check the docs.

Avatar
Nicolaas

Forum Moderator, 224 Posts

10 October 2007 at 11:07am

Edited: 10/10/2007 11:37am

Hi,

Thanks for your response.... I had already added the database fields. No problems there - I think. Here is the whole class:

static $icon = "...";
static $db = array(
'Quote' => 'Text',
'Person' => 'Text',
'Organisation' => 'Text'
);
static $has_one = array(
'Photo1' => 'Image',
'Photo2' => 'Image'
);
public function nextPager() {
$pages = DataObject::get("SiteTree", "ParentID = ($this->ParentID + 0) AND Sort > ($this->Sort + 0 )", "Sort", "", 1);
if($pages) {
foreach($pages as $page) {
$v = '<a href="#subHeading-'.$page->URLSegment.'" onclick="return !showHide(\''.$page->URLSegment.'\');">next: '.$page->Title.'</a>';
}
}
return $v;
}

public function previousPager() {
$pages = DataObject::get("SiteTree", "ParentID = ($this->ParentID + 0) AND Sort < ($this->Sort + 0)", "Sort DESC", "", 1);
if($pages) {
foreach($pages as $page) {
$v = '<a href="#subHeading-'.$page->URLSegment.'" onclick="return !showHide(\''.$page->URLSegment.'\');" >previous: '.$page->Title.'</a>';
}
}
return $v;
}
}