Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » new image field

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

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

Page: 1
Go to End
Author Topic: 1643 Views
  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    new image field Link to this post

    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

  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    Re: new image field Link to this post

    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

  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    Re: new image field Link to this post

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

  • jam13
    Avatar
    121 Posts

    Re: new image field Link to this post

    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.

  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    Re: new image field Link to this post

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

    1643 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.