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.

Archive

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

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

new image field


Reply

5 Posts   1666 Views

Avatar
Nicolaas

9 October 2007 at 2:06pm (Last edited: 9 October 2007 4:18pm), Forum Moderator, 213 Posts

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

9 October 2007 at 2:09pm Forum Moderator, 213 Posts

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

9 October 2007 at 2:11pm Forum Moderator, 213 Posts

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

9 October 2007 at 11:41pm 121 Posts

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

10 October 2007 at 11:07am (Last edited: 10 October 2007 11:37am), Forum Moderator, 213 Posts

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;
}
}