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.

Archive /

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

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

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


Go to End


62 Posts   109893 Views

Avatar
bummzack

Community Member, 904 Posts

3 October 2008 at 6:34pm

@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

Forum Moderator, 801 Posts

4 October 2008 at 1:35am

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

Avatar
bummzack

Community Member, 904 Posts

8 October 2008 at 10:56am

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

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: http://bummzack.ch/hasmanyfilemanager/ 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

Forum Moderator, 801 Posts

8 October 2008 at 11:17am

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

Avatar
erwanpia

Community Member, 63 Posts

10 October 2008 at 12:51am

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
bummzack

Community Member, 904 Posts

10 October 2008 at 1:11am

Edited: 10/10/2008 1:12am

@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

Community Member, 63 Posts

10 October 2008 at 1:44am

Edited: 10/10/2008 1:45am

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
bummzack

Community Member, 904 Posts

10 October 2008 at 2:08am

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;
}