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

Controlling Uploadify files from templates


Go to End
Reply


12 Posts   2363 Views

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

18 March 2011 at 7:18am

Hi there,

I'm lost with this part of Silverstripe. I've been using it succesfully from 2 years or more, but one feature i never understood is to upload several files into a simple pagetype.

So, after days of trying different modules, i've uploades DataObjectManager module and Uploadify.

I must say that documentation is not so clear on these ones, but i've managed to get them working on a future site i'm planning to launch.

I've followed the instructions on Uploadify module, and i've sucesfully uploaded several documents into the MyPageWithFiles page type on my test site

Now, the question is:

How do i control those files from the templates? I don't have the knowledge to code that. Is documented somewhere? Am i missing installing another module?

thanks in advance,

Eduardo

Avatar
UncleCheese

Forum Moderator, 4096 Posts

18 March 2011 at 7:34am

<% control YourFileObjects %>
$Field1 $Field2, etc..
<% control YourFileRelation %>
$URL $Size $Extension, etc...
<% end_control %>
<% end_control %>

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

18 March 2011 at 7:42am

Uncle,

Thanks very much from your quick answer!

In my case i have 2 pagetypes as you explain on the tutorial:

MyPageWithFiles.php

<?php
class MyPageWithFiles extends Page {

   static $has_many = array (
      'AttachedFiles' => 'MyFile'
   );

   public function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Content.Files", new MultipleFileUploadField('AttachedFiles','Upload several files'));
      return $fields;
   }
}

class MyPageWithFiles_Controller extends Page_Controller {

   /**
    * An array of actions that can be accessed via a request. Each array element should be an action name, and the
    * permissions or conditions required to allow the user to access it.
    *
    * <code>
    * array (
    * 'action', // anyone can access this action
    * 'action' => true, // same as above
    * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
    * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
    * );
    * </code>
    *
    * @var array
    */
   public static $allowed_actions = array (
   );

   public function init() {
      parent::init();

      // Note: you should use SS template require tags inside your templates
      // instead of putting Requirements calls here. However these are
      // included so that our older themes still work
      Requirements::themedCSS('layout');
      Requirements::themedCSS('typography');
      Requirements::themedCSS('form');
   }
}

MyFile.php

<?php
class MyFile extends File {

   static $has_one = array (
      'MyPageWithFiles' => 'MyPageWithFiles'
   );

}

Is this right?

How it would be the code for the calls you've stated previously on your first answer?

Thank you very much

Ed

Avatar
UncleCheese

Forum Moderator, 4096 Posts

18 March 2011 at 8:02am

In that case, you would just use:

<% control AttachedFiles %>
$URL $Extension $Size etc..
<% end_control %>

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

18 March 2011 at 8:09am

THANK YOU VERY MUCH!

it worked great! i need this implementation because i'm planning to place a slideshow with 'n' files, and it the past i hardcoded each slideshow, pretty unfuncitional.

Do this variables documented in some place?

I have one last question:

i've saw your tutorials explaining the sort capability on the Uploadify module, and you said something like there is a module installed wich allows you to do that, can you tell me how to do it? because i don't understand you clearly (my english is fair, i'm from Buenos Aires)

thank you very much, great work you've done here! :)

Ed

Avatar
UncleCheese

Forum Moderator, 4096 Posts

18 March 2011 at 8:52am

Glad it worked for you!

If you have DataObjectManager installed, the files should be sortable when using a MultipleFileUploadField.

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

18 March 2011 at 9:39am

Uncle,

I have the field declared as you say, but i cannot drag the item, it appears de cross over each item, but i cannot sort them.

There is something i don't understand:
You tell me "if i have dataobjectmanager installed", yes, i have it installed, and the question is:

Isn't suppossed that i MUST install it in order to uploadify work properly?

In fact, i had problems with DataObjectManager installation, since there's missing the classic "install.txt" file that appears on each module, and by now i left the module on /DataObjectManager

Maybe that's causing some problems?

Thank you again

Ed

Avatar
UncleCheese

Forum Moderator, 4096 Posts

19 March 2011 at 4:10am

The DataObjectManager module should be installed in a folder named "dataobject_manager", not "DataObjectManager"..

Go to Top