2

I've developed a Shoutbox extension and would like to implement a feature, by which you can tag a user in a shout (same concept as tagging a user on JSE) using the @ symbol and then the user's name.

However I'm not sure which approach to go with.

Option 1:

Get all usernames from the #__users table on page load and return maybe a json object. Then populate a container with names from the json object that match your query.

Option 2:

You start typing a name (@Lod) which then initiates an Ajax request to query the #__users table


Option 1 could be a bit heavy if the #__users table is extremely big, however the matching would be much quicker and vise versa for Option 2.

Which approach (other suggestions welcome) would be the best to go with?

3

2) for sure. An Ajax query is a small load. It does not block and return the whole users table. You can have better control. For example, returning only 3 attempts.

On the other hand 3) is a method to access the users table and a possible attack vector. For example to guess usernames, count users in your site, etc.

1

Your project only needs access to an array in json format. I'm more in the option 1 camp. Get your data once and never again.

If you are worried about load on your database, there are work arounds for that. You could store a .json file of user handles -- completely ready to drop into your .js declaration. You could update the .json file whenever a new registration is verified.

How does Stackexchange do it? They keep everything lean and quick by limiting who can be pinged on any given page. By restricting the communication in this way, the whole user pool is not searched, just the active members (and special players) with in the scope of the conversation.

As for scrapers, if anyone wants to scrape all of the handles off your site, you are going to have a hard time stopping them. Best not to even factor that aspect into your decision.

  • Json file sounds good. This would require a custom plugin though if it needs to be updated. I believe SE use ElasticSearch – Lodder May 28 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.