PDA

View Full Version : Folder Icon Hack


09-30-2000, 10:25 PM
I just whipped out a new hack last night after taking a look though the new hacks at ubbhackers.com. I like to get ideas by seeing what the ubb guys are doing. Our hacks are so much easier to create than the equivalent ubb version.

This hack will place a small dot on the folder icons in forumdisplay if you have participated in that topic. You can see my new folders with dots at

http://www.hedgehogwheels.com/forums/showthread.php?threadid=1244

This hack took quite a bit of re-writing of the vB search facility so I will not be releasing it right away. I am going to make sure it works fine than we can hope John has rewritten the search as it is a big kludge as it stands now.

The hack needed to check each topic that displayed on forumdisplay to see if the user had posted in that thread. The easiest way would just be run a query as each topic is processed and see if the user has a post in the post table with that threadid. I did not want to do this I don't want to add any more queries to the main pages as we know how that can slow down big sites. New queries in global.php, index.php, forumdisplay.php and showthread.php should be avoided if possible. I noticed that each thread contains a "userindex" which already contains each person who posted in that thread. Great I though BUT (a bg but) each name is stored in this field separated by a space. What happens if a user has a space in their name? This is where we get the problem with the search. The search uses this field when you click the little "search posts by this user" or you put in a username on the search page. It simply searches for the usernames surrounded by spaces. The problem is that if you have a user named "joe" and a user named "joe blow", you will always get Joe Blow's posts back when you search for Joe's. This is bad and it has always bugged my about vB. So what I did was rewrite the function that creates the userindex (is done when you post/edit posts) to separate the names by a "|". I then disallowed users from using "|"'s in their names. You could use anything, a comma, whatever. Now when I search for "joe blow", I only get joe blow's posts and not Joe's. I also discovered why you can't search for users that have ampersands in their names. John uses urlencode() to send the username to the search function on a redirect line. The problem is urlencode/urldecode seems to eats &'s so I still need to fix that bit.


.. Back to the hack .. So know I just read the userindex from the thread table, as the threadid is already being read so I don't have to do any new queries.

So let me know what you think but I hesitate to release this as it requires you to re-do the search engine, requires you to pick a character that can't be in a username (means you have to find one none of your users have). It's a kludge of a kludge and the underlying code could very well change greatly in the next version since as it is now it doesn't work properly.

10-01-2000, 06:41 AM
I think you should release it.

For one, this is a two-in-one hack. It'll both improve the search feature AND add the dot thing.

As for the char you need to seperate, I think a comma should be good enough. I mean, have you ever seen a user with a comma in his username? ;)