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.

Archive

Our old forums are still available as a read-only archive.

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

HasManyFileManager: New CMS module/extension. Testers/review needed


Reply

62 Posts   104216 Views

Avatar
banal

3 October 2008 at 6:34pm Community Member, 901 Posts

@Ingo
That would be awesome, yes.
Somehow i didn't get e-mail notification on this thread any more. The last notification i received was for the post by Hamish.. odd. Or i just didn't log in to the forums for a while :)

Anyway: yeah! I'd love to put the module on your SVN. I'm quite busy at the moment but hopefully i'll find some time to enhance the module or write a proper documentation.

Avatar
Ingo

4 October 2008 at 1:35am Forum Moderator, 801 Posts

Cool, the module is now available in svn at http://open.silverstripe.com/modules/hasmanyfilemanager

Avatar
banal

8 October 2008 at 10:56am Community Member, 901 Posts

Hello all.
The documentation for the HasManyFileManager is now online. Please let me know if i forgot something important.
[url]http://doc.silverstripe.com/doku.php?id=modules:hasmanyfilemanager[/url]

Sources have been updated as well. I added a bit of documentation in the code and fixed some bugs. A thanks goes to BO_Einzeller who already fixed several Bugs in the old version. Get the current sources here: [url]http://bummzack.ch/hasmanyfilemanager/[/url] or checkout the SVN trunk:

svn co http://svn.silverstripe.com/open/modules/hasmanyfilemanager/trunk/ filemanager

I'll build a release version soon, hopefully it will make it to the modules page :)
Have fun!

Avatar
Ingo

8 October 2008 at 11:17am Forum Moderator, 801 Posts

aaawesome, thanks for putting this much effort into good documentation, its an important part :)

Avatar
erwanpia

10 October 2008 at 12:51am Community Member, 63 Posts

Hi, well done for this extension, I am currently testing the 0.3 and adde the following modification

instead of extenting SiteTree and ContentController I extend Page and Page_Controller

that allows me to use my main site template. Seems to work fine on FilePage for the moment

E.

Avatar
banal

10 October 2008 at 1:11am (Last edited: 10 October 2008 1:12am), Community Member, 901 Posts

@erwanpia
Ah. Yes, sure! The FilePage is only meant as an example. You can use the HasManyFileManager Field/Control in any of your own pages... maybe i should clarify that in the documentation.
The FilePage.php is actually at the wrong place. It isn't a required component of the Module and therefore shouldn't be in the filemanager/code folder really. Maybe i'll remove the file from the module sources and just put the code into the documentation as a explanation.

Avatar
erwanpia

10 October 2008 at 1:44am (Last edited: 10 October 2008 1:45am), Community Member, 63 Posts

Thks for the answer. I find it nice to get the FilePage as a sample of what can be done.

I'm now trying to extend the image decorator but can't get the Sitetree drop down to work. I got inspiration form the redirector Page type but without success yet.

class AttachedFile extends DataObjectDecorator
{
   // get the additional DB Fields
   public function extraDBFields() {
      return array(
         'db' => array(
            'Grouping' => 'Varchar(255)',
            'DestLink'=> 'Varchar(255)'
         ),
         'has_one' => array(
            'SiteTree' => 'SiteTree',
            "LinkTo" => "SiteTree"
         ),
         
      );
   }

...

   public function getMyCMSFields(){
      /**
       * FIXED: Value is only shown if theres an existing entry.
       * Otherwise we get some crappy stuff in the Title
       */
      $fields = new FieldSet(
         new TextField('Title', _t('AttachedFile_Uploader.TITLE', 'Title'),($this->owner->ID) ? $this->owner->Title : ""),
         new TextField('DestLink', _t('DestLink', 'DestLink'),($this->owner->ID) ? $this->owner->DestLink : ""),
         new TreeDropdownField(   
                  "LinkToID",
                  _t('RedirectorPage.YOURPAGE', "Page"),
                  "SiteTree"
               )
      );
      return $fields;
   }

Avatar
banal

10 October 2008 at 2:08am Community Member, 901 Posts

Hi erwanpia

If i were you, i wouldn't modify the AttachedFile directly. You'll have a hard time updating to another version of the HasManyFileManager if you mix in your own code. I recommend that you implement your own Decorator as described in the documentation (see the MyFile Source-code example). You can then put that code into your mysite/code directory, this way you have all your code nicely bundled in one directory.

Concerning your problem: That's most likely because there aren't all required JavaScript Libraries loaded inside the iframe. I'm afraid some of the form fields won't work inside the iframe due to JavaScript Libs that are missing. You could add them to the AttachedFile_Uploader::iframe method, but that would be a hack once again :)

If you don't have too many pages, you can solve it with a regular dropdown. like this:

public function getMyCMSFields(){
$items = DataObject::get('SiteTree');
$values = array();
foreach($items as $item){
$values[$item->ID] = $item->Title;
}

$fields = new FieldSet(
new TextField('Title', _t('AttachedFile_Uploader.TITLE', 'Title'),($this->owner->ID) ? $this->owner->Title : ""),
new TextField('DestLink', _t('DestLink', 'DestLink'),($this->owner->ID) ? $this->owner->DestLink : ""),
new DropdownField('LinkToID', _t('RedirectorPage.YOURPAGE', "Page"), $values, $this->owner->LinkToID)
);
return $fields;
}