Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » ss2.4 ImageField problem

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

Page: 1
Go to End
Author Topic: 1052 Views
  • slavelabourer
    Avatar
    Community Member
    25 Posts

    ss2.4 ImageField problem Link to this post

    So I need dynamic image slider for a homepage. Pretty standard so i copy pasted it from a 2.3 site done 6 months ago. This code works on 2.3 but 2.4 the fields don't appear in the cms, any suggestions? thanks guys.

    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {
    static $db = array(
       

    );
    static $has_one = array(
          'AdSpace1' => 'Image',
          'AdSpace2' => 'Image',
          'AdSpace3' => 'Image'
    );

    }

    function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace1', "Ad Space 1"), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace2', "Ad Space 2"), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace3', "Ad Space 3"), 'Content');
          return $fields;
       }

    class HomePage_Controller extends Page_Controller {

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    public function init() {
          parent::init();

          Requirements::themedCSS("layout");
          Requirements::themedCSS("typography");
          Requirements::themedCSS("form");
          
    Requirements::javascript('mysite/javascript/jquery.js'); //jquery library
    Requirements::javascript('mysite/javascript/jquery-cycle.js'); // plugin
    Requirements::javascript('mysite/javascript/myCustomCycle.jquery.js'); // controller

    Requirements::block('jsparty/jquery/jquery.js');
    Requirements::block('jsparty/jquery/jquery_improvements.js');
    Requirements::block('jsparty/prototype.js');
    Requirements::block('jsparty/prototype_improvements.js');
    Requirements::block('jsparty/prototype15.js');

              // Requirements::javascript('mysite/javascript/supersleight.js'); // transparency hack for ie   
              // Requirements::javascript('mysite/javascript/supersleight-min.js'); // transparency hack for ie
       }
    }
    ?>

  • slavelabourer
    Avatar
    Community Member
    25 Posts

    Re: ss2.4 ImageField problem Link to this post

    So I see that I left a } out in the last post, fixed but still hasnt fixed my problem now the grey area where the form should be appears but no form

    static $has_one = array(
          'AdSpace1' => 'Image',
          'AdSpace2' => 'Image',
          'AdSpace3' => 'Image'
          );
       
       function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace1', "Ad Space 1"));
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace2', "Ad Space 2"));
          $fields->addFieldToTab('Root.Content.Main', new ImageField('AdSpace3', "Ad Space 3"));
          return $fields;
       }
    }

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