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

Preview: DataObjectManager module


Reply


379 Posts   61973 Views

Avatar
SilverRay

Community Member, 167 Posts

20 June 2009 at 6:16am

Yes, I dl'd from this link:

http://www.carlinowebdesign.com/assets/Uploads/dataobjectmanager3.zip

Avatar
SilverRay

Community Member, 167 Posts

20 June 2009 at 6:18am

So, in Safari it is like this:

http://cheese.textdriven.com/sprintf_safari.png

Avatar
SilverRay

Community Member, 167 Posts

20 June 2009 at 6:21am

Edited: 20/06/2009 6:23am

Code I used (just for testing this):

<?php

class SalesArea extends DataObject {

   public static $db = array(
      'Area' => 'Varchar(100)'
   );
   
   public static $has_one = array(
      'OrderPage' => 'OrderPage'
   );
   
   function getCMSFields_forPopup() {
      $fields = new FieldSet();
      $fields->push( new TextField('Area', 'Sales Area'));
      return $fields;
   }

}
?>

and

<?php

class OrderPage extends Page {
   
   public static $db = array(
   );
   
   public static $has_one = array(
   );
   
   public static $has_many = array(
      'SalesAreas' => 'SalesArea'
   );

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

      $areaTablefield = new HasManyDataObjectManager(
         $this,
         'SalesAreas',
         'SalesArea',
         array(
            'ID' => 'ID',
            'Area' => 'Sales Area'
         ),
         'getCMSFields_forPopup'
      );

//      $areaTablefield->setPageSize(100);
      $areaTablefield->setAddTitle('a Sales Area');
//      $areaTablefield->setParentClass("OrderPage");
      $fields->addFieldToTab( 'Root.Content.OrderForm', $areaTablefield);

      return $fields;
   }

}

class OrderPage_Controller extends Page_Controller {
   
}

?>

Avatar
CubeDave

Community Member, 8 Posts

10 August 2010 at 2:27pm

Hello.

I'm lucky enough to be another person benefiting from the great plugin DataObjectManager, and the SimpleTinyMCEField that comes with it. I do have one question however, my client's requirement is that the link popup that SimpleTinyMCEField uses has the same functionality as the link panel when using the full-featured tiny mce editor.

The current link popup allows only entering of a url, and selection of the target specifier and alt text. However my client requires the dropdown that is dynamically populated with the site's pages, and the one that contains all the files uploaded too. Basically everything in the EditorToobarLinkForm.

Is this possible? And if so, how might I go about implementing it?

Thanks again
-dave

Avatar
UncleCheese

4086 Posts

10 August 2010 at 2:51pm

No, there's no elegant way to do that, unfortunately. Tried many times, but at the end of the day, DOM is for editing dataobjects, not pages. If you have that much content, you should consider using a standard SiteTree model.

Avatar
CubeDave

Community Member, 8 Posts

10 August 2010 at 3:00pm

A fair point UncleCheese.

In this instance, the page is constructed from blocks, each of which is a DataObject-derived class containing a title and some html. This html wants to be able to link to another page on the site, hence the requirement for a more complex link popup.

If you could suggest a better way of implementing this, I'm certainly all ears, but at this stage I'm stuck with it.

I'd say in general that if you want to edit some html on a site, where-ever that html is displayed within the site, it's valuable to be able to link to other pages within the site in a simple way.

If you have a moment, could you perhaps elaborate briefly on what stood in your way when looking for an elegant solution to this problem?

Thanks again for your great work
-dave

Avatar
UncleCheese

4086 Posts

10 August 2010 at 3:51pm

First of all, that panel is a component of CMSMain.. It's not even part of HtmlEditorField. Second, it's an absolute nightmare of spaghetti Javascript that the SS team themselves has told me is in dire need of an overhaul. So even if it were as easy as porting it over to the popup window, I wouldn't want to bring that mess into my work.

We always just have our clients enter absolute URLs using the link button. You don't have to worry about the links changing in the future because the back link tracking handles that, so it's almost as good as an ID.

Avatar
kindlemanwill

Community Member, 68 Posts

1 August 2011 at 8:19pm

Hello,

I'm trying to add a file picker to one of my content types. I want a has-one style relationship so the user just picks one file.

I have downloaded the DOM and got it going. Once files are chosen they are displayed with radio buttons beneath so i can choose which one to use.

Have I done this in the best way? The HasOneFileDataObjectMapper it seems like I should only be to attach one file.

So, to recap - I'm just wondering if using HOFDOM is the way to do this and have i done it right?

Thanks,

Will

I'm on SS 2.4, and v new to ss. so apologies if this is a stupid question.

$manager = new HasOneFileDataObjectManager(
         $this, // Controller
         'Mediarelease', // Source name
         'Media', // Source class
         'Attachment', // File name on DataObject
         array(
            'Name' => 'Name',
            'Description' => 'Description',
            'Category' => 'Category'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );

class Media extends DataObject
{
   

   static $has_one = array (
      'Attachment' => 'File',
      'ResearchPage' => 'ResearchPage'
   );

   public function getCMSFields_forPopup()
   {
      return new FieldSet(
         new FileIFrameField('Attachment')
      );
   }
}