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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Attempting Agile Carousel Module


Go to End


2 Posts   2354 Views

Avatar
theoldlr

Community Member, 103 Posts

21 November 2009 at 11:14am

I am attempting to build a module for the agile carousel (www.agilecarousel.com). This is also the first module I will have written for SilverStripe so I hope I'm not biting off more than I can chew. I started off reading the tutorial that guides you through the randomlinks module, but comments and forum posts lead me to believe that some of these methods are outdated.

I have started to put together classes, and am using ModelAdmin for adding to the CMS (see attached). I'm hoping to gain some understanding of data relationships and using them to make the CMS interface powerful from this thread.

My basic idea for this was to allow for creating slides in the CMS (for now enter html code with text/image). Allow for creating carousels by assigning a title(i.e. home page carousel), and finally letting the user select which slides are included on each carousel. At the moment I am getting an error when I click the create carousel button. "Fatal error: Call to a member function dataFields() on a non-object in C:\website\cs\sapphire\forms\Form.php on line 821"

I'm assuming this is because of a bad relationship. Here is my code so far:

AgileCarouselAdmin.php:

class AgileCarouselAdmin extends ModelAdmin {
    
    public static $managed_models = array(
        'Carousel',
        'Slide'
     );    
    static $url_segment = 'agilecarousel';
    static $menu_title = 'Agile Carousel';
}

Carousel.php:
<?php
  class Carousel extends DataObject {
    
    static $db = array (
    'Title' => 'Varchar'
    );
 
    static $has_many = array(
        'Slides' => 'Slide'
    );   

    function getCMSFields_forPopup() {
      $fields = new FieldSet();
      $fields->push( new TextField('Title') );
      return $fields;
   }
 
    function getCMSfields()  {
        $fields  = parent::getCMSFields();
        
        $tablefield = new HasOneComplexTableField (
            $this,
            'Slides',
            'Slide',
            array(
                'Title' => 'Title'
            ),
            'getCMSFields_forPopup'
        );
    }
    
  }

Slide.php:
<?php
class Slide extends DataObject {
    static $db = array(
        'Title' => 'Varchar',
        'Code' => 'HTMLText'
    );
}

Expertise, tutorials, references--any help is really appreciated!

Attached Files
Avatar
davidm2010

Community Member, 107 Posts

24 November 2009 at 4:09am

This is exactly what is needed to improve the looks of a home page. I wish I understood this better, I would help. But it is what is needed. If you get it solved, please post here.

David