Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

A new suggestion field for SilverStripe


Go to End


3 Posts   1331 Views

Avatar
Nivanka

Community Member, 400 Posts

16 June 2009 at 7:07pm

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
Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 June 2009 at 1:29am

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.

Avatar
Nivanka

Community Member, 400 Posts

17 June 2009 at 1:55am

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/