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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Bug Reports


Go to End


297 Posts   102002 Views

Avatar
Pike

Community Member, 42 Posts

21 November 2010 at 1:58am

I then, you'd change in DataObjectManager.php line 500, this code:

Before:

new LabelField('show', _t('DataObjectManager.PERPAGESHOW','Show').' '),
new DropdownField('PerPage','',$map, $value),
new LabelField('results', ' '._t('DataObjectManager.PERPAGERESULTS','results per page'))

After:

new LabelField('show', _t('DataObjectManager.PERPAGESHOW','Show').' ',null,true),
new DropdownField('PerPage','',$map, $value),
new LabelField('results', ' '._t('DataObjectManager.PERPAGERESULTS','results per page'),null,true)

Reason: I sent translation fo cs_CZ and sk_SK. After changes I see string correctly. I cannot send files (images) to be more see-able.

Avatar
MarijnKampf

Community Member, 176 Posts

25 November 2010 at 12:56am

I'm using Uploadify/DOM 521 and I'm running into an issue with using the same image for multiple purposes. It could be this is a limitation of the SS file system rather than Uploadify/DOM.

My setup: I've added a Thumbnail Image to the page class, and I'm using DOM + Uploadify to add a list of files (Downloads) to an Example. Multiple examples are displayed on a single page using the Examples page type. The Downloads / Example classes are based on the code provided on the Uploadify documentation page.

The issue I have is on adding an image as the thumbnail of a page, and then adding the same image as an Example download the Thumbnail disappears from the page. I believe this is due to the fact that the ClassName in the File table is changed from Image to Download.

Is there a way that allows multiple uses of the same file still using DOM+Uploadify?

I've included trimmed down test code below.

mysite/code/Page.php

<?php
class Page extends SiteTree {
	public static $has_one = array(
    'Thumbnail' => 'Image',
	);

	function getCMSFields() {
		$fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Thumbnail", new FileUploadField('Thumbnail', 'Thumbnail'));
		return $fields;
	}

}

class Page_Controller extends ContentController {

}

mysite/code/Examples.php

<?php
class Examples extends Page {
	static $has_many = array (
		'Examples' => 'Example'
	);

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab("Root.Content.Examples", new DataObjectManager(
			$this,
			'Examples',
			'Example',
			array('Title' => 'Title', 'Description' => 'Description'),
			'getCMSFields_forPopup'
		));

		return $fields;
	}
}

class Examples_Controller extends Page_Controller {

}

mysite/code/Example.php

<?php
class Example extends DataObject {
	static $db = array (
		'Title' => 'Text',
		'Description' => 'HTMLText'
	);
	static $has_one = array (
		'ExamplesPage' => 'Examples',
		'Thumbnail' => 'Image'
	);
	static $has_many = array (
		'Downloads' => 'Download'
	);

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab("Root.Content.Downloads", new MultipleFileUploadField('Downloads','Select downloads'));
		return $fields;
	}

	public function getCMSFields_forPopup() {
		$fields = new FieldSet(
			new TextField('Title','Title'),
			new SimpleHTMLEditorField('Description','Description'),
			new ImageUploadField('Thumbnail','Thumbnail'),
			new MultipleFileUploadField('Downloads','Select download files')
		);
		return $fields;
	}

}

mysite/code/Download.php

<?php
class Download extends File {
	static $has_one = array(
		'Example' => 'Example'
	);
}

Avatar
UncleCheese

Forum Moderator, 4102 Posts

25 November 2010 at 8:41am

You're using the "choose existing" tab to do that? I think that's going to give you trouble because the classnames are different. You're going to have to upload the same file twice..

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
MarijnKampf

Community Member, 176 Posts

25 November 2010 at 10:09am

That's what I feared, as I suggested uploading the same file twice as a workaround to the user, but I do feel that's a bit counter intuitive. Is there a way to use the same file? Or alternatively limit the assets sub folder that can be selected (to force the user to upload the file again...)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

25 November 2010 at 10:25am

Well, what you're describing doesn't make a whole lot of sense. I know for the user it's weird, but if you think about it, you're asking that a single file have two different ClassName fields simultaneously. That's just not going to work.

Is the thumbnail always the same as the other upload? You could just get rid of that field all together and assign the ThumbnailID on write..

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
MarijnKampf

Community Member, 176 Posts

25 November 2010 at 7:58pm

I can see how the SilverStripe DB/file implementation is limiting in this respect.

The thumbnails are completely independent from the uploads. The issue is that setting an image to an upload breaks the thumbnail on other unrelated pages if it happens to be the same file.

Two different possible solutions (I think):
- Download is currently extended from File, could the solution be to extend Download from both File and Image?
- Is it possible to restrict the assets source folder used in Uploadify?

Avatar
fabeat

Community Member, 2 Posts

29 December 2010 at 5:39am

Hi!

I think the encoding of the german language file for the uploadify module should be UTF-8 :)

https://gist.github.com/gists/757396/download

Cheers, Fabian

Avatar
s!m

Community Member, 9 Posts

5 January 2011 at 1:56am

I've updated the german language files for DOM, ImageGallery and Uploadify as those were not available by the time I needed those...
As I see, the now active german language files all include characters like "ä,ü,ß", etc while those should possibly be "&auml;, &uuml, etc..". So I rewrote those files and translated all items with "&auml;, etc." so that the problems with the encoding of the files are gone... :-)

I also found one untranslatable string in DataObjectManager_holder.ss:
line 3, it says:

<p>You may add $PluralTitle once you have saved for the first time.</p> 

where it should be something like this:
<p><% sprintf(_t('ADDAFTERSAVE','You may add %s once you have saved for the first time.'),$PluralTitle) %></p> 

To translate this line I added the following to my "de_DE.php"-language file:
$lang['de_DE']['DataObjectManager_holder.ss']['ADDAFTERSAVE'] = 'Sie k&ouml;nnen %s hinzuf&uuml;gen, sobald Sie das erste Mal gespeichert haben.';

If anyone's interested, here are the links for those three language files, maybe they are useful to someone...
DOM: http://pastebin.com/iCbN1M2Q
ImageGallery: http://pastebin.com/SQuEhNv0
Uploadify: http://pastebin.com/ZfB7sjhM

Best regards,
s!m