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: 59995 Views
  • micahsheets
    Avatar
    Community Member
    164 Posts

    Re: Preview: DataObjectManager module Link to this post

    Uncle Cheese,
    I used your Testimonials example as a basis for my own Testimonials class and TestimonialsPage type. My page type first displays a random testimonial and then I have previous and next buttons that I want to page through all of the testimonials one by one. I tried using what you added to the image_gallery for next and prev albums as a basis to add this to my TestimonialsPage. However I cannot figure a way for my adjacentTestimonial() function to know the ID of the randomly selected initial Testimonial. I don't know how to set up parameters inside a class and even if I did have a parameter that would hold the Testimonial DataObject I need there is no way of making sure my currentTestimonial function runs before the NextTestimonial and PrevTestimonial functions run so that variable could very well be null and I couldn't get the ID so I could get the next or previous one from the Testimonials table.

    Maybe the problem could be approached this from a completely different angle.

    One more note: In your ImageGalleryPage.php file that I am using as reference for prev/next functionality, $this->current_album is set in SingleAlbumView() and tested in CurrentAlbum() however I am not sure how this works as I can't find where that is declared.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    If you want a truly random order with pagination, you need to do one of two things:

    1) Bring down the DataObjectSet of randomly ordered testimonials all into one page and navigate between them with Javascript
    2) Store a session variable that is an array of the initial sort order of testimonials, and once set, use that to navigate your testimonials.

    Apart from that, I don't know that you can randomly order a record set with every refresh of the page and expect coherent results.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Preview: DataObjectManager module Link to this post

    @micahsheets
    This is a different angle, may or may not be what you are looking for:

    All I would do is generate a random set of testimonials (either a limited set or all of them) ie :

    function getRandomQuote() {
    return DataObject::get("Testimonial","", "RAND()", "",6);
    }

    output on the template, something like:

    <div id="testimonials" style="display:none">
    <% control getRandomQuote %>
    <div class="testimonial-text">$Testimonial</div
    <div class="testimonial-author">$Author</div>
    <% end_control %>

    <div class="controls"><a id="prev" href="#" >prev</a><a id="next" href="#" >next</a></div>

    </div>

    then use jQuery cycle (or something similar) to allow you to page through the testimonials.

    I hide the div first so you don't get the whole lot of them showing at the start, then use jquery to unhide once the page has loaded. jquery should look something like:

    $(document).ready(function(){   

    $('#testimonials').cycle({
          prev: '#prev',
          next: '#next',      
          timeout: 0
          });   
    $('#testimonials').show();      
    });

    I've used it for images here, but it should work equally well for text-based content.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Preview: DataObjectManager module Link to this post

    I've been trying for the last few days to implement front-end searching through dataobjects. I've looked through the wiki & forum and tried lots of options, but buggered if I can get it sorted. Has anyone successfully implemented a dataobject search (ie a keyword search through 2 or more dataobject feilds) that you could share??

  • Victor
    Avatar
    Community Member
    128 Posts

    Re: Preview: DataObjectManager module Link to this post

    $resultsF = DataObject::get("FacultyPage"," `lastname` LIKE '".$data['LastName']."%' AND `firstname` LIKE '".$data['FirstName']."%'");

    HTH. Victor

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @victor -- LIKE is not a reliable search function to use since it doesn't allow natural language. For instance, searching "Silverstripe camp" will not match the record "Silverstripe summer camps"

    @Tsunami -- Glad you asked. I was just about to post this as a snippet. I had to do this for a client on Friday. Took a long time, but it came out pretty good. I built a class called CustomSearchForm, a subclass of SearchForm, which by default searches SiteTree and File, and you add more classes to it.

    $form->addCustomClass('MyDataObject');

    There are a few things you need to add to your dataobject class like:

    $searchable_fields = array ('Author','Quote');

    I'll post it soon. Works pretty well. You can actually test it at http://riskpayments.bluehousegroup.com. Search on anything in the Knowledge Base section. Those are all GlossaryTerm dataobjects, and you'll see they come up in the site search.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Preview: DataObjectManager module Link to this post

    @UncleCheese
    cool...i look forward to seeing it:)
    since I seem to be finding uses for dataobjectmanager in all sorts of different places in my projects, search ability was sooner or later gonna be an issue....I'm glad you cracked it & I can stop banging my head against the wall! Thanks

  • robinp
    Avatar
    Community Member
    33 Posts

    Re: Preview: DataObjectManager module Link to this post

    @UncleCheese if you don't think the DataObjectManager module is the solution for what do think the solution could be ? it's working quite well I've made to dataobject_manager/javascript/dataobject_manager.js line 105 like hu suggested.

    cheers

    robin

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