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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Redirect and Description on FileIFrameField


Reply


3 Posts   428 Views

Avatar
Pipifix

Community Member, 54 Posts

3 February 2012 at 3:58am

Edited: 03/02/2012 4:19am

Hello

at the moment i try to understand the whole dataobject-thing. my goal is to set some images with a caption and a redirect to different pages. the templaterendering should used on the homepage by a jqery-imageslider (orbit). do i have to use FileIFrameField on a getCMSFields function? or getCMSFields_forPopup. I need to bind the description and the redirect to the CostumImage.

My code for the dataobject so far.

<?php
class CustomImage extends DataObject {
   //db fields
   static $db = array (
'Description' => 'Varchar(100)'
);

   /**
    * Our custom image class contains one image that is used on one page.
    */
   public static $has_one = array (
      'SliderImage' => 'Image',
      'PageRedirect' => 'SiteTree'
   );

   /**
    * Popup for editing a single image.
    *
    * @return FieldSet The iframe for editing the image.
    */
   public function getCMSFields(){
      return new FieldSet(
         new FileIFrameField('SliderImage')
      );
   }   
}

in HomePage i've got

   public static $has_many = array(
   'CustomImages' => 'CustomImage',
   );

function getCMSFields() {
      $fields = parent::getCMSFields();
      
      //SliderImages
      $images = new ImageDataObjectManager(
   $this,
   'CustomImages',
   'CustomImage',
   'SliderImage'
      );
      
      
      return $fields;
   }
}

Is there a good tutorial about the FileIFrameField or HasManyComplexTableField. Thanks for your help.
Pipifix

Avatar
Pipifix

Community Member, 54 Posts

3 February 2012 at 5:28am

The Desription is working. But the sitetree dropdown does'nt work.
My code for the function getCMSFields in CustomImage.php

public function getCMSFields(){
      return new FieldSet(
         new TextField('Description'),
         new TreeDropdownField('PageRedirectID','Bild verlinkt zu','SiteTree'),
         new FileIFrameField('SliderImage','Bild für den Slider', Null, Null, Null, 'Uploads/homepage-sliderimages/')
      );
   }

why is the dropdown not visible? is this a fact of the popup?

Pipifix

Avatar
Pipifix

Community Member, 54 Posts

11 February 2012 at 2:51am

Sorry for the crosspost. I moved this issue to this thread: http://www.silverstripe.org/dataobjectmanager-module-forum/show/8358?start=8#post311609

Thanks, Pipifix