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.


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


62 Posts   104224 Views


11 October 2008 at 6:12am Community Member, 63 Posts

First off, Banal thank you. This is a great addition to silverstripe. Thank you for your hard work.

I installed this mod on a development site, and it worked fine. I went to install this on a live production site soon after and encountered some errors.

I think I have narrowed down the errors to having something to do with the ecommerce module. The development site I initially installed this on did not have ecommerce but once I put ecommerce on there, I received the same errors that I received on the other site.

this is the debug output.

FATAL ERROR: DATABASE ERROR: Couldn't run query: SELECT `File`.ID, `File`.ClassName, `File`.Created, `File`.LastEdited, `File`.Name, `File`.Title, `File`.Content, `File`.ParentID, `File`.Filename, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName, `File`.PopupWidth, `File`.PopupHeight, `File`.Embed, `File`.LimitDimensions FROM `File` LEFT JOIN `Product_Image` ON `Product_Image`.ID = `File`.ID WHERE (File.SiteTreeID = 8) AND (File.Grouping = 'MyImages') ORDER BY Grouping, Sort | Column 'Grouping' in order clause is ambiguous
At line 431 in /var/www/vhosts/

any ideas?


11 October 2008 at 6:41am Community Member, 901 Posts

There seems to be a conflict between the File Table and the Product_Image Table. Both seem to have a Grouping field.
I changed my code, so that it's no longer ambiguous.

You can get the updated code from SVN or just replace Line 15 of filemanager/code/SiteTreeFileHandler.php with the following line:

public function AttachedFiles($group = '', $sort = 'File.Grouping, File.Sort'){

Hope that helps!


11 October 2008 at 6:58am Community Member, 63 Posts

Thanks Banal, my apologies if this was discussed earlier in the thread and I missed it. I am extending this module to be able to show random uploaded images and link each image to the sponsor page. This made it tons easier.


11 October 2008 at 7:19am Community Member, 901 Posts

Don't apologize. This was an issue i wasn't aware of and i fixed it right now, after you posted the problem.
I hope you post a link to the site, once it's done so we can all enjoy :)


11 October 2008 at 8:11am Community Member, 63 Posts

Don't apologize. This was an issue i wasn't aware of and i fixed it right now, after you posted the problem.
I hope you post a link to the site, once it's done so we can all enjoy :)

Cool, I helped out! :-D

Will do. I got the random image working with your module, and it handles the link to image relationship as well. pretty easy. If anyone would like to see the code just let me know.

Thanks again Banal


13 October 2008 at 8:47am Community Member, 9 Posts


I would like to be able to attach pdf's to a type 'page' which will have an article, but have the pdf's upload to a certain folder which has already been created.

Is this possible?


13 October 2008 at 10:30am Community Member, 901 Posts


If you want to upload just one pdf per page, you don't really need the HasManyFileManager and you could simply use the FileField (or FileIFrameField) Class. By setting the last parameter of the constructor, you can change the upload folder for the file.

If you need multiple files per page, you can use the HasManyFileManager, but you have to change some things in order to get your files created in the desired folder.
You can change the base folder in the file AttachedFile.php on line 76

static $baseFolder = 'Uploads/AttachedFiles';

Whenever you create a HasManyFileManager you also specify a name, that is used for file grouping. This also creates a subfolder where files belonging to that group are being stored. You should consider this behavior too!

Example: If you need your files to be in Uploads/PDF, you should set the $baseFolder to 'Uploads' and the group name of the HasManyFileManager to 'PDF'.

Hope that helps.


13 October 2008 at 9:16pm Community Member, 9 Posts

Is there anyway of overriding the upload folder in the pagetype:

For example this is my page type:


class Screening extends Page {
   static $db = array(
   static $has_many = array(
   'Files' => 'File',
   function getCMSFields() {
   $fields = parent::getCMSFields();
   static $baseFolder = 'Uploads/Programme-Notes/Season-2008-2009';
$manager = new HasManyFileManager(
'PDF', // name -> will be used for file grouping
'Files' // relation name defined in $has_many
// creating tab for the "Files" Manager
$fields->addFieldToTab('Root.Content.Files', $manager, $baseFolder);

    return $fields;
   //static $icon = "tutorial/images/treeicons/news";
   public function onBeforeDelete(){


class Screening_Controller extends Page_Controller {



I also have a gallery page for all programme notes by season, which is why I would like to specify where the files will go. Sometimes there will be more than one file, maybe images too.