tags:

views:

89

answers:

3
+2  Q: 

Tag Conventions

Currently, these are the preparations I'm making:

  1. Convert to lowercase.
  2. Strip HTML tags.
  3. Check if tag already exists

Are there any other things that I consider?

note: Tags may be in Arabic.

here the method i use

function sanitize_tag($tag){

//strip slashes
if(get_magic_quotes_gpc()) {
    $tag = stripslashes(trim($tag));
} 
//Remove white spaces
$tag = preg_replace('/\s\s+/',' ',$tag);
$tag = trim($tag);
$tag = ltrim($tag);
$tag=filter_var($tag, FILTER_SANITIZE_STRING);
return $tag;

}

A: 

Another common practice is to replace spaces and punctuation. Beyond that, I think you've got a solid list of preperation-steps for making a site-ready tag.

Jeff and Joel recently mentioned another interesting practice during the Stack Overflow Podcast #79 regarding tags. While discussing MathOverflow (MO), they relized that MO was using a tag-abbreviation setup where each tag was prepended with an abbreviated version of itself:

Rather than having the tag statistics, they have st.statistics. This allows you to quickly search for all "statistics" questions by inputting "st." as opposed to the abmiguous "statistics," which would be a candidate for partial matches, returning items like "population statistics," etc.

Jonathan Sampson
thank you man ,by the way iam doing tagging in arabic if you have any other comment
islam
A: 

Having all tags in lower case will make it easier to privent duplicates, and, as a user, I believe it's a nice feature... But it might not always please your users, for instance if the use a name as a tag.

Maybe it would be better to use the case they typed the first time they entered the tag ?


Stipping HTML tags is nice ; I would also remove spaces (replace them by a dash, for instance), and other characters that don't look great in URLs, like quotes, slashes, accents ("éàèç", ...), ponctuation marks, ...


In any case, don't forget to escape the tags before injecting them into SQL queries or to your HTML output ;-)

Pascal MARTIN
thank you very much man
islam
by the way iam doing tagging in arabic if you have any other comment
islam
You're welcome :-) ;; sorry, I can't really help you about arabic, though :-(
Pascal MARTIN
A: 

If you are going to implement a FULLTEXT tag searching scheme (like mysqlicious), make sure that your tags do not include word separators.

Say, a dash (-) is a word separator in MySQL, while an underscore (_) is not.

So a search like this:

MATCH(tags) AGAINST ('+server' IN BOOLEAN MODE)

will incorrectly return sql-server but (correctly) will not return sql_server.

Quassnoi
than you for interest but iam using Toxi iplementaion
islam
@islam: Toxi will work on any tagging scheme.
Quassnoi