Hashtags
Tags are used in a lot of forum software as either an addon or a default feature. Hashtags are used in social networks like Twitter and Facebook. Forum posts often turn in to more than just the original topic and become a conversation. Conversations evolve with many topics so the original post might not directly pertain to the last.
Okay, enough about that. We all know what hashtags are. #hashtag #forum #addon #maybeDefaultFeature #wouldBeReallyCool
Anyway... this isn't something I'm likely to develop right now so if anyone wants to tackle it, I'll post how I'd do it.
On the display page, just use a preg_replace for #hashtag and replace with a link to the view tags action.
I don't think there's any reason to have anything more on the post page than making the hashtag bold on the WYSIWYG editor.
On post, just grep the hashtags. There will be two tables, hashtags and post_hashtags. Hashtags is two fields: id_tag and tag (varchar). post_hashtags is id_tag and id_post. After thinking through this, I think post_hashtags needs to have a timestamp for trending. It will also have to remove hashtags, so compare that as well.
Then we need some actions. ?action=hashtag with two subactions: &sa=search &sa=trending
When you click a hashtag it will take you to the search action with &tag=[your hashtag]. Or, if there is no tag to search, it just shows a search screen and the trending beneath that. The trending subaction will show the "hot" tags.
Searching just looks for posts that match the tag. That's easy. The hard part is the trending and the permissions. Speaking of permissions, add a couple for search_tags, view_trends.
Thinking about settings and number of tags to trend should be one of them. Maybe default is 5. Frequency of trending update: 1/hour. Maybe on the search page, group topics?
Should posts that you can't see contribute towards trends? I think if they didn't, the query becomes extremely difficult.
Re: Hashtags
Reply #1 –
Instead of having a "search" subaction, just make the default action "search" and if there is a tag to search for, it will replace ?action=hashtags;sa=search;tag=myhashtag
Oh, before placing in the hashtags table, lowercase the string.
Re: Hashtags
Reply #3 –
Yeah, that's a wee bit different from hashtags though.
Okay, trending is going to be pretty difficult to calculate. If it's on a site like this one, where you don't get 1000 posts a day, it might not get any trending posts, especially if nobody is using hashtags. So should it show "Nothing is trending right now, use hashtags to start some trends" or should it keep digging deeper until it finds something to make a trend?
I think that might be a setting for the admin because digging deeper can cause some massive load.
Here's how I'm thinking it needs to be done. First, it will have to calculate how many posts with hashtags are made per hour. So, a query where it groups by the hour that the message was posted in the past 24 hours. It can be a longer time or a shorter time (maybe use a throttle there) but it probably should have a granularity of no greater than an hour and the span should be no less than 24 hours. Then it will start adding hours until it reaches 100 hashtags, also another throttle. Might want to have more than 100 to make a trend. After it figures out how many hours it needs to use, it will group by the tag and count, ordering by count. Then it will pick the top 5 or 10 or whatever the admin chooses. It will then cache those tags to the settings table.
Am I missing anything?
Obviously trending can only work as a scheduled task or cron.
Re: Hashtags
Reply #6 –
Hi! There is progress with the hashtag and trends?