Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Controlling Uploadify files from templates

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 2189 Views
  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Controlling Uploadify files from templates Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Controlling Uploadify files from templates Link to this post

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

  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Controlling Uploadify files from templates Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Controlling Uploadify files from templates Link to this post

    In that case, you would just use:

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

  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Controlling Uploadify files from templates Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Controlling Uploadify files from templates Link to this post

    Glad it worked for you!

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

  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Controlling Uploadify files from templates Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Controlling Uploadify files from templates Link to this post

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

    2189 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.