Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Cant seem to implement SimpleImageField and ImageField in SS 2.4.5

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 571 Views
  • kharmer
    Avatar
    Community Member
    8 Posts

    Cant seem to implement SimpleImageField and ImageField in SS 2.4.5 Link to this post

    Hi All,

    I am trying to implement an image field for a cusatom page type. This is what I have in my class that extends Page.

       static $db = array(
          'Subtitle'             => 'Text',
          'TitleImage'          => 'ImageField',
       );
       static $has_one = array(
       );

       /* admin icon */
       static $icon = 'themes/bayer/images/treeicons/folder-blue';
       
       /* allowed child page types */
       static $allowed_children = array('');

       function getCMSFields() {
          $fields = parent::getCMSFields();

          /**/
          // Remove fields
          /**/
          //$fields->removeFieldFromTab("Root.Content.Main","Content");
          $fields->removeFieldFromTab("Root.Content.Main","Excerpt");
          $fields->removeFieldFromTab("Root.Content.Main","isNew");
          $fields->removeFieldFromTab("Root.Content.Main","ArticleDate");
          $fields->removeFieldFromTab("Root.Content.Main","lastEditDate");
          $fields->removeFieldFromTab("Root.Content.Main","isNewTimeoutDate");
          $fields->removeFieldFromTab("Root.Content.Main","featurePage");
          $fields->removeFieldFromTab("Root.Content.Main","featurePageProblemSec");
          $fields->removeFieldFromTab("Root.Content.Main","bgMark");
          $fields->removeFieldFromTab("Root.Content.Main","moreLink");
          // $fields->removeFieldFromTab("Root.Content.Main","MenuTitle");
          
          /**/
          // Add
          $fields->addFieldToTab('Root.Content.Main', new TextField('Subtitle', 'Page subtitle (right under main title)'), 'MenuTitle');
          $fields->addFieldToTab('Root.Content.Main', new ImageField('TitleImage', 'Page title image (top right corner)', null, null, null, "Fungicide"), 'MenuTitle');
       }

    When I go to the admin side and try to edit a page using this page type, I get errors!! I get the popup error with an SQL statement issue.

    Any ideas!?

    I'm stuck on SS 2.4.5 as I have in herited this project and upgrading it out of scope!

    Any help very much appreciated,
    K...

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Cant seem to implement SimpleImageField and ImageField in SS 2.4.5 Link to this post

    While in the CMS you need to use the FileIFrameField

    571 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.