SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Advice on new category added text

    Hi Guys,

    when a user logs into my site i wanted to add a "JUST ADDED" sign next to categories uploaded since they last logged in, once they see the new categories the "JUST ADDED" sign dissapears, i'm not sure the best way to go about it and help would be great.

    cheers

    Graham

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a relationship table for that, which will store user-category pairs. When a category is added, add record to the relationship table for each user. Same applies when user signs up in the system. When user views a category, remove the corresponding user-category pair from the relationship table. You can also consider some prunning, so all categories older than N days are considered to be viewed by all users.

  3. #3
    SitePoint Zealot glowdot's Avatar
    Join Date
    Jun 2007
    Location
    Santa Monica, CA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by earl-grey View Post
    Use a relationship table for that, which will store user-category pairs. When a category is added, add record to the relationship table for each user. Same applies when user signs up in the system. When user views a category, remove the corresponding user-category pair from the relationship table. You can also consider some prunning, so all categories older than N days are considered to be viewed by all users.
    This can get pretty massive in some situations.

    If you have a lot of users, one thing I've considered in the past is an extra field in the users table with a sort of "status" code.

    Assign a power-of-two value to each category, and when it gets updated, add that value to the current value of each user. Once they view it, subtract the value.

    When displaying categories, then, you'd need to factor out the value to figure out which categories are "on" or "off". This could be done with a simple AND though.

    So let's say you have 5 categories, numbered 1,2,4,8 and 16, and an int field in the users table named cat_status.

    When you update category 2 and 8, add 2 and 8 to each user. So let's say user glowdot now has cat_status 10.

    When viewing the category list, take my cat_stat AND 8 and see if the value is > 0. It is, so display the NEW tag next to the category. Then subtract 8 from my cat_status.
    Advertise on Glowfoto
    banners as low as $25/month, text ads $10/month
    Share 10 million impressions per month!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •