Jump to:

7940 Posts in 1543 Topics by 946 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: 61131 Views
  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi there, just more info of the bug reported a post above. I have tried on another OSX system, the popup worked as expected in Safari and in Firefox the popup appeared but only contained the statement "I can't handle sub-URLs of a CMSMain object."

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    @ howardgrigg, I had this same issue and can't for the life of me remember what was causing it. I ended up fixing it though, it was something I was doing wrong in the code. I'll do my best to remember what it was. Good luck!

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

    Cause of the issue mentioned in my post of 1 April 2009 at 10:03am:

    http://open.silverstripe.com/changeset?old_path=%2Fmodules%2Fsapphire%2Fbranches%2Fnestedurls%2Fforms%2FForm.php&old=73041&new_path=%2Fmodules%2Fsapphire%2Ftrunk%2Fforms%2FForm.php&new=HEAD

    Using the line from trunk, the pop-up's save button works correctly; with the line from nestedurls, it does not.

    Ben

    .

    My post of 1 April 2009 at 10:03am:
    I'm running revision 103 of DataObjectManager against revision 73881 of trunk. When I click the "save" button on the "add" pop-up window, the object I'm trying to add never gets saved to the database. Instead, I get sent to some kind of page that has an add link and a search box, etc.

    The "add" pop-up window's form tag is as follows:
    <form id="DataObjectManager_Popup_AddForm" action="admin/EditForm/field/Articles?ctf[Articles][per_page]=10&ctf[Articles][showall]=0&ctf[Articles][sort]=Created&ctf[Articles][sort_dir]=DESC&ctf[Articles][search]=&ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">

    Is that the correct action? It looks funny to me.

  • Aaron Brockhurst
    Avatar
    Community Member
    30 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi Uncle Cheese

    Fantastic work! The DataObjectManager is just what I needed.

    Do you have an example of how to setup ManyManyDataObjectManager? I want to use it to enable users to select images to go in the right column on the page and have have the ability to have different images on everypage. I might have missed something but when I use DataObjectManager it puts the same objects on every page.

    Thanks

    Aaron

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi, Aaron.

    Great use of the DataObjectManager. I'd recommend using a ManyManyFileDataObjectManager if I were you, since it will display the images in a grid for you, as well as streamline the upload process.

    If you have the many_many relation set up correctly, it should be the same as a ManyManyComplexTableField, only with one more argument.

    new ManyManyFileDataObjectManager(
    $this,
    'MyImages'
    'MyImage',
    'Image' // The fieldname on the $has_one array of your MyImage dataobject.
    array( // headers...
    'getCMSFields_forPopup'
    );

    You can read more in the documentation in the SS wiki.

  • micahsheets
    Avatar
    Community Member
    164 Posts

    Re: Preview: DataObjectManager module Link to this post

    Uncle Cheese. Thank you for all your hard work and help.

    I would like to use the Testimonials page type to manage testimonials. I have set up the page so that I can add testimonials and I can see the database table where they are stored. What I don't know how to do is randomly grab a Testimonial and display it on any give page on the site. My guess is that in the Page_Controller I would have a function that could select a random Testimonial from the database and display the Testimonial Content and Author on my page. I don't need a page that shows all of the Testimonials.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Page_Controller

    function RandomTestimonial()
    {
    return DataObject::get_one("Testimonial", null, true, "RAND()");
    }

    FYI: Please do not rely on the example code included with dataobject_manager. I'll be removing it soon. You can recreate it in mysite/code if you want.

  • Amir Mostofi
    Avatar
    Community Member
    59 Posts

    Re: Preview: DataObjectManager module Link to this post

    I have a simple question regarding the display of content in a template. I'm using FileDataObjectManager and my files are as follows:

    Partner.php
    -----------
    <?php
    class Partner extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'URL' => 'Text'
       );
       
       static $has_one = array (
          'Logo' => 'File',
          'PartnerPage' => 'PartnerPage'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextField('URL'),
             new FileIFrameField('Logo')
          );
       }
    }
    ?>
    -----------

    PartnerPage.php
    -----------
    <?php
    class PartnerPage extends Page
    {
       static $has_many = array (
          'Partners' => 'Partner'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new FileDataObjectManager(
             $this, // Controller
             'Partners', // Source name
             'Partner', // Source class
             'Logo', // File name on DataObject
             array(
                'Name' => 'Name',
                'URL' => 'URL'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
          
          // If undefined, all types are allowed. Pass with or without a leading "."      
          $manager->setAllowedFileTypes(array('jpg','gif'));
          
          // Label for the upload button in the popup
          $manager->setBrowseButtonText("Upload (JPG or GIF only)");
          
          // In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
          $manager->setGridLabelField('Name');
          
          // Plural form of the objects being managed. Used on the "Add" button.
          // If left out, this defaults to [MyObjectName]s
          $manager->setPluralTitle('Partners');
                
          $f->addFieldToTab("Root.Content.Partners", $manager);
          
          $f->removeFieldFromTab('Root.Content', 'HeaderImage');      

          return $f;
       }

    }

    class PartnerPage_Controller extends Page_Controller
    {
    }
    ?>
    -----------

    PartnerLogo.ss
    -----------
       <% if Partners %>
       <div id="partners"><div class="container">
          <div id="partner-logos">
          <ul>
             <% control Partners %>
             <li class="partner-logo"><a href="#" title="$Name" style="background-image: url('$Logo.URL')"><span>$Name</span></a></li>
             <% end_control %>
          </ul>
          </div>
       </div></div><!-- end #partners -->
       <% end_if %>
    -----------

    Can anyone tell me why the above template file PartnerLogos.ss does not return any Partners, when in the CMS I clearly have added records using dataobjectmanager and I can see them under the Partners tab in the CMS?

    61131 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.