Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Help with basic table - managed via modelAdmin - with display limit & multiple page results

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
Go to End
Author Topic: 2518 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Well, that's a separate issue. We're talking about javascript behaviours now, and you can handle that anyway you want, really, but the old "onclick" attributes are not really a good practice anymore. They were 3 or 4 years ago, but it's not really compliant with the MVC framework to mix Javascript and HTML anymore. Attach that event handler unobtrusively with a framework like jQuery.

    Or, the "inline label" plugin for jQuery does it automatically for you, actually.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Glad it's working for you, by the way. Do you mind if I post this tutorial on my blog? It actually came out pretty nice and concise!

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    sure go ahead!
    can you leave out the website URL though? (its a client site so better if it doesn't end up in tutorials!)

    also, when you create the tutorial, can you improve some of the field names?
    for example, you labelled the search input field "s" which is fine, but if you elaborated on names, it helps me see the links better between different pieces of code just a suggestion.

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    P.S - im in the process of working with the latest trunk of eCommerce (0.6) that Jedateach and co. are improving.
    do you have any experience with it?

    its all working pretty well so far, but theres a few issues im having and could do with some expert advice!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Nope, I wouldn't touch that module. Sorry. There are far too many solid thirdparty solutions out there to be tinkering with the native SS ecomm module, IMO.

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    hmmm this is true... but how easily are the other solutions integrated with SS?
    or do you mean just dont use SS at all for ecommerce sites?

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Hi again, so my client requested that seraching by part number too was actualy required.
    so i've returned to your earlier post about multiple search fields, here's the code i've updated. all seems to work fine:

    public function doProductSearch($data, $form) {
    if(isset($data['s'])) {
    $filters = array();
    foreach(Product::$searchable_fields as $field) {
    $filters[] = "$field LIKE '%".Convert::raw2sql($data['s'])."%'";
    }
    $filter = implode(" OR ", $filters);
    }
    return array (
    'ProductList' => $this->ProductList($filter)
    );
    }

    the only thing not great now, is when your search returns no results, nothing happens. it just shows the default list. how easy is it to display an "your search returned no results" message?
    also, is there a way we can include the search query in the result page? just to clearly show that it worked.
    even if the search term remained in the search field would be better than what it currently does.
    if the search is quite generic, you might not even notice that it worked as the list doesnt change much and there is no success message... does that make sense?

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    P.S - I've already got my catalogue.ss template configured (i think)
    with:

    <% if ProductList %>
    $ProductList.sort(Title)
    <% control ProductList %>

    TABLE HERE

    <% end_control %>
    </table>
    <% else %>
        <p>Sorry, your search query did not return any results.</p>
    <% end_if %>

    so having no ProductList returned will show the error message that i want. but how do i make the function return nothing if no matches are found?

    2518 Views
Page: 1 2 3 4 5
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.