Jump to:

11003 Posts in 2735 Topics by 1824 members

All other Modules

SilverStripe Forums » All other Modules » A new suggestion field for SilverStripe

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 843 Views
  • Nivanka
    Avatar
    Community Member
    395 Posts

    A new suggestion field for SilverStripe Link to this post

    Hi,

    I was working on a suggestion form field, I was discussing about this at the google group too, Anyway I'd like to extend the module, and make it a useful plug in.

    I am attaching the module here, if you can help me with testing and can give me more ideas that will be great.

    Attached Files
  • UncleCheese
    Avatar
    4085 Posts

    Re: A new suggestion field for SilverStripe Link to this post

    Looks good. Haven't used it, but a couple things come to mind:

    - You're requiring the user to custom code his own suggestion() AJAX call for every instance of the form field. This may work for users who have really specific functionality, but for most of us, we're going to want that to work out of the box, without any custom coding. It seems to me, you could make it more modular, and add a SuggestionField_Controller class that contains a generic suggestion() function for the AJAX call. You could even assume that the two fields you're looking for are Title and Link, and the user could override those in the constructor.

    - You should use MATCH and AGAINST instead of LIKE.

    - To get the $URL variable, you can save yourself a lot of trouble and use $('base').attr('href');

    - In your Javascript, the line "jQuery.noConflict()" does nothing unless you return that to a variable, for example:

    $J = jQuery.noConflict(); $J('#my-element').hide();

    - For the suggestion function in the Javascript, you're going to need to use submission throttling to prevent a sequence of rapid AJAX requests. For those of us who are fast typists, we're only going to want to see one ajax call when we're done typing. Not ten of them all at once, one for each keystroke. I did this in the Search function of DataObjectManager if you want an example. You need to store a setTimeout resource and nullify it everytime the user hits a key within say, 0.5 seconds of the last one.

    Very nice, though. This is a great idea.

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: A new suggestion field for SilverStripe Link to this post

    hi UncleChees,

    thanks for your comments, actually some nice ideas.

    About the jQuery.noConflict(); this helps the users to use any other javascript library as well. Sometimes silverstripe too uses prototype, and it can cause conflicts. So this prevents it.

    This does need some custom coding, but yet it has some features, it can call to any server using CURL or anything, all you have to do is that return the results in a JSON object. other than that some comments I got was running it through SilverStripe can be slow, so if someone can code up his own php code to run outside then you can have that either.

    Also about the setting an interval can be useful.

    And on the first post I forgot to mention the demo URL for this.

    Here it is

    http://open.whynotonline.com/suggestion-field/

    843 Views
Page: 1
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.