Jump to:

7912 Posts in 1355 Topics by 930 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Go to End
Author Topic: 54241 Views
  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese, I added a few lines of code to FileDataObjectManager that allows me to set the upload folder. Would you like these additions? If so, should I just attach it here to a post? Something else that would be nice is if I delete an image from the page it would also delete the image (or file) from the server. Of course this isn't always the desired behavior so it should have three settable states: leave, delete, or prompt. Prompt would ask the user if they want to remove from the page or remove and delete from the server. Of course there are other things to consider like the _resampled images associated with the deleted images. Another thing my code doesn't support, if you change the name of the page it would be nice if the image directory name changed and all the DB references to it.

    Back to work...

  • schellmax
    Avatar
    Community Member
    126 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese, for me too this is an extremely useful module as it enhances the core functionality for a very common task.
    just a note on this:
    you might consider removing the demo classes 'ResourcePage' and 'TestimonialPage' from the module code, or find some other means of distributing them. they splatter the 'create' dropdown when installing the module.
    thanks for all that great work!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @ drye - Please send me the code and I'll ratify it and check it into the SVN. Thanks for that. I've been meaning to get around to that request.

    @schellmax - I know, I know.. I've painted myself into a corner on this one. I did at one time remove the example code from the SVN and people went nuts because they had all build sites that relied on those classes. I need to come up with a carefully planned "exit strategy" for that example code.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hello, DataObjectManager users!

    Let me first say that this has been a very rewarding project to have worked on, and all of your positive feedback and encouragement is very much appreciated. I'm really glad so many of you have found a use for the module. It's been far more popular than I ever expected.

    That said, I'd like to throttle the energy behind the project as much as I can and get to the point that it is a powerful and robust solution for all kinds of content management in Silverstripe. Can everyone start contributing their feature requests and bug reports so I have a nice list to work off of for the next version? Here's what I have on the map right now, ordered by priority:

    - Add default upload folder selection (already completed by Drye, but needs to be integrated)
    - Get a comprehensive look at all the javascript bugs that are tripping up the popup window.
    - Images should display as thumbnails of their content, rather than an icon.
    - Figure out what's going on with Linux vs. SWFUploadField.
    - Add pagination to popup
    - Integrate with Files & Images section to replace AssetTableField.
    - Integrate with ModelAdmin. (I have very limited experience with ModelAdmin, so anyone who can contribute to this end, please do).
    - Add validation to popup (not likely any time soon).

    Anything else?

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    I updated straight from subversion and then merged my changes. I've tested with my setup and it works great, but that doesn't mean its perfect.

    See attached file.

    Attached Files
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Perfect. Just checked it in. One more thing off the list!

    Only thing i changed was giving $uploadFolder a default value of "Uploads". The Upload class expects the $path to be either a string or false. Since we're passing it in no matter what, seemed appropriate to define the string so it never comes in null or empty.

    Nice job, Drye!

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi, I've looked everywhere I can think of, but just can't get this to work...... in my template can I reference the page from inside the dataobject (ie using $Parent or something like that)??

  • Howard
    Avatar
    Forum Moderator
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi UncleCheese,

    I have had a go at adding adjustable width columns with help from simon in the irc. I can style the heading columns without a problem but for some reason can't set the width of the columns containing the Item values. I was probably trying to do it wrong - any advice? Here is the code I have implemented.

    ## ExamplePage.php ##

          $manager->setColumnWidths(array(
             'Name' => '20',
             'PlanningComment' => '60',
             'Date' => '20'
             ));


    ## DataObjectManager.php ##

    public function setColumnWidths($Widths)
       {
          $this->ColumnWidths = $Widths;
       }

    public function Headings()
       {
          
       $headings = parent::Headings();
    foreach($headings as $heading) {
    $heading->IsSorted = (isset($_REQUEST['ctf'][$this->Name()]['sort'])) && ($_REQUEST['ctf'][$this->Name()]['sort'] == $heading->Name);

    $Widths = $this->ColumnWidths;

    $heading->Width = (isset($Widths[$heading->Name]) ? $Widths[$heading->Name] : self::$default_heading_width);

    if(isset($_REQUEST['ctf'][$this->Name()]['sort_dir']))
    $dir = $_REQUEST['ctf'][$this->Name()]['sort_dir'] == "ASC" ? "DESC" : "ASC";
    else
    $dir = "ASC";
    $heading->SortDirection = $dir;
    $heading->SortLink = $this->RelativeLink(array(
    'sort_dir' => $heading->SortDirection,
    'sort' => $heading->Name
    ));

    }
    return $headings;

       }


    ## DataObjectManager.ss ##

    <% control Headings %>
                   <div class="col $FirstLast" style="width: $Width%">
                      <div class="pad">
                            <a href="$SortLink">$Title &nbsp;
                            <% if IsSorted %>
                               <% if SortDirection = ASC %>
                               <img src="cms/images/bullet_arrow_up.png" alt="" />
                               <% else %>
                               <img src="cms/images/bullet_arrow_down.png" alt="" />
                               <% end_if %>
                            <% end_if %>
                            </a>
                      </div>
                   </div>
                   <% end_control %>

    54241 Views
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.