How-to build tagging system like SO ?
I’m using a unique textbox on my asp.net mvc website to submit “tags”.
First of all, i tried to split tags with commas “asp.net, c#, sql server”.
It works but if user forgot to seperate tags with commas i’ve a problem to split that string.
“asp.net c# sql server” : sql server should be a single tag, not two “sql” + “server”.
Moreover i “can’t” (he should not take care about this …) ask user to use “-” character to seperate words of the tag : “sql-server”
Someone help ?
either you match the string for existing tags, so then you can have tags with spaces (assuming you search for the bigger tags first so you find ‘sql server’ before you search for ‘sql’. You could make this more robust by only allowing existing tags to be used, and have a separate mechanism for creating new tags. That way users could easily create tags with spaces, as anything entered in the new tag box would be a single tag like ‘sql server 2005’.
EDIT:
Alternatively you could have some special syntax in the tags for creating new ones:
‘sql,asp.net,[NEWTAG]sql server,c#’ would use existing tags ‘sql’,’asp.net’,’c#’ and would create a new tag ‘sql server’
/EDIT
or you split on spaces and don’t allow tags with spaces
in your example how do you tell the difference between ‘sql server’ (1 tag) and ‘sql’ ‘server’ (2 tags)?
if you look on SO the tags are all space separated, so one tag is sql-server.
As long as you have the tags suggested to them as they are entering them I don’t think this will be a problem