Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to End
Author Topic: 59981 Views
  • pcbender
    Avatar
    Community Member
    20 Posts

    Re: Preview: DataObjectManager module Link to this post

    Thanks for the reply.

    The call to $Attachment.Type returns no value in the example below:

    <% if Resources %>
             
       <ul>
       <% control Resources %>
          <li><a href="$Attachment.URL">Download $Name $Attachment.Size and $Attachment.Type and $Category</a></li>
       <% end_control %>
       </ul>
    <% end_if %>

    Off Topic:

    Is there some way to programatically identify the fields and methods available to a view or template? For example:

    <% if Resources %>
       $ShowMembers
       <ul>
       <% control Resources %>
          <li><a href="$Attachment.URL">Download $Name $Attachment.Size and $Attachment.Type and $Category</a></li>
       <% end_control %>
       </ul>
    <% end_if %>

    The $ShowMembers call would return a list of members callable from the view.

    THanks,

    PC

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    As far as the Type property is concerned, I was just taking a guess. I'm not really sure of all the properties available for the File class. Check the docs/API.

    By creating a function such as $ShowMembers, you're breaking the MVC pattern by bundling presentation into your controller. That's what control blocks are for.

    <% control Members %>
    <li>$Name</li>
    <% end_control %>

    Edit: sorry. I misread your request, thinking you meant Members as in users. I would look at the "Built in template controls" topic in the docs first. Anything beyond that is accessible in either the model or controller of your page or object as a property or method.

    public $MyProperty = "foo"
    public function MyFunction() {
    return "bar";
    }

    $MyProperty $MyFunction

    returns "foo bar"

    Further, any named relation in your model gets a magic method.

    $has_many = array ('Objects' => 'MyClass');

    now grants you the function

    $this->Objects();

    Or on the template:

    <% control Objects %>

  • pcbender
    Avatar
    Community Member
    20 Posts

    Re: Preview: DataObjectManager module Link to this post

    Thank you very much. You are a tremendous asset to the SS community.

    BTW, it is $Attachment.FileType

    PC

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese, Have you ever thought about modifying the popup to have the save button on the bottom next to the close button? Just a random thought.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Good idea, but unfortunately, not likely to happen. The save button needs to be in the iframe and the close button needs to be on the popup window itself. The next enhancement I make to the FileDataObjectManager, and by transference, the ImageGallery, is to add a "Stop Captioning" button next to save that will give the users a more intuitive way to stop the post-upload walkthrough if they wish.

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    Uncle Cheese, Noticed that a boolean displays in the table as a 1 or 0. Could this be a checkbox instead? Possibly even editable from the table view?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    That's true with any TableField. Make sure you build a custom getter.

    static $db = array (
    'MyBool' => 'Boolean'
    )

    public function getMyBool()
    {
    return $this->MyBool ? "Yes" : "No";
    }

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    Thanks, Actually I was already trying something like this:

       public function getPublish()
       {
          $field = new CheckboxField('Publish','Publish this content?',$this); [EDIT]
          $field->useLabelLeft(false);
          return $field;
       }

    But it only displays the checkbox, it doesn't accept the changes...
    http://pastie.org/415959

    59981 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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.