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

DataObjectManager : <% sprintf(....) %> displayed on the website


Reply

48 Posts   8441 Views

Avatar
UncleCheese

23 February 2010 at 5:44pm 4085 Posts

Sure..

$f->removeByName('SWF');

and you can remove requirements in the init() function of your subclass

Requirements::block("some_requirement.js");

Avatar
DsX

23 February 2010 at 5:46pm Community Member, 178 Posts

Sweet.... THANK_YOU

Avatar
DsX

26 February 2010 at 8:22am (Last edited: 26 February 2010 8:23am), Community Member, 178 Posts

I have this working rather nicely right now (from my humble point of view)
I have created a subclass of SlideshowProPage called SlideshowPage
taken out a couple unneeded attributes and added calls to a couple different templates depending on the player used (copies of you XML method really)
I am working on setting up the page template right now, although I may not use it...

I am wondering 2 things.. Do you see any future problems with this approach? (I would like to have it require little maintenance for upgrades) and Is there a way to tell SlideshowProPage not to be listed in the pagetypes available?

sorry, 1 other thing.. is it possible to extend SlideshowProPage to allow SWF and FLV files? My slideshow player supports them and that would be very cool.

thanks.

Avatar
UncleCheese

26 February 2010 at 8:49am 4085 Posts

To hide the parent page use

static $hide_ancestor = "SlideshowProPage";

FLV is entirely possible. You would just have to change the ImageGalleryManager field to a standard FileDataObjectManager. If you have FFMPEG installed, FileDOM will encode and thumbnail video uploads on the fly.

Avatar
DsX

26 February 2010 at 9:06am Community Member, 178 Posts

Very cool... I'm getting excited.

I am learning so much with this... ;)

I have the page type removed... who knew that would be so easy.

I am a little lost about the next change though since that is in the grandparent of the class that I am working with right now.

Avatar
UncleCheese

26 February 2010 at 10:21am 4085 Posts

Yeah, that's definitely tricky. Start with $fields->removeByName('GalleryImages'); (I think that's the relationship managed by ImageGalleryManager.. check ImageGalleryPage.php..

Then,

$fiends->addFieldToTab(... new FileDataObjectManager($this,'GalleryImages'... etc));

It will definitely take some programming chops, but it seems like you're well on your way. Good job with the subclassing and keeping the changes insulated from the core. That's the beauty of the Silverstripe framework. Takes a little extra time, but it's so much cleaner.

Avatar
DsX

26 February 2010 at 11:40am Community Member, 178 Posts

OK, I'm getting way lost here... So far based on going through the ImageGallery code and SlideShowPro code this is what I have..

      $f->removeByName('GalleryItems');
      
      $FLVvideo = new FileDataObjectManager($this,
         'GalleryImages', // Source from ImageGalleryPage.php
         'ImageGalleryItem', // class from ImageGalleryItem.php
         'FLVattachment', // File name on DataObject
         array(
            'Caption' => 'Caption',
            'ImageGalleryPage' => 'ImageGalleryPage',
            'Album' => 'Album'),
         'getCMSFields_forPopup'
      );
      
      $f->addFieldToTab("Root.Content.SWF", new FileDataObjectManager($this,$FLVvideo);

I assume that FLVattachment is taking the place of the previous file relation?
Not sure I have the either of the Class or Source references correct, although they do look to be correct from what I found in your source. Do I have any other syntax error?? I'm getting a syntax/parse error/ class exists ()

I'm trying to use the example here: http://doc.silverstripe.org/doku.php?id=modules:dataobjectmanager

I may need to step back a bit and try some samples from scratch.

Avatar
UncleCheese

26 February 2010 at 12:14pm 4085 Posts

Yeah, the more I look at it, it seems like it would take more time to reverse engineer the thing into submission than it would to just build it from the ground up. ImageGallery gives you a lot of things you don't need, and you're just going to waste your time fighting with it.

I would just start with a page with a FileDOM .. use setAllowedFileTypes() to include all image extensions, and video extensions..

Then basically replicate the xml() function to give SSP a feed that it will like..

When looping through your images in the XML template, you could do something like

<% if ClassName = Image %>
<xml tag for image />
<% else_if ClassName = FLV %>
<xml tag for flv /> use $FLVLink to get the link to the encoded FLV
<% end_if %>