• Resolved ThomasK702

    (@thomask702)


    Hello WordPress Community!

    We are wondering if there is a way to implement some kind of a tracking feature into our website that will display a “New Content” label/tag on the drop down menu items that a user has not clicked on. This function would also be great as a label on a post list page, to show which posts have been clicked on and which have not. Any help or a point in the right direction is greatly appreciated. My programmer is out of town for the week, so i am getting the research done so that he can work on it when he gets back.

    Check out the drop down menu here:
    http://www.firstintro.biz
    select the one titled “President’s Club”
    the first menu that comes up contains category pages, and when hovered over, a list of the 10 most current posts in that category are displayed.

    Thanks again!

    -Thomas

Viewing 4 replies - 1 through 4 (of 4 total)
  • wpismypuppet

    (@wordpressismypuppet)

    Interesting situation… there are quite a few things to think about when attempting to “track” a user’s experience. For instance, do you need it to work all the time, no matter where the user visits the site from? In other words, if I visit the site from home, then check it from work, should my work machine indicate things I’ve already read?

    Basically I can think of two ways to do this… the first is simply using cookies and the already present “visited” links which is already tracked in the browser. Combining these two options, you could easily accomplish your task. It is volatile though, meaning that after a few weeks (depending on the client’s browser settings) all those visited links will be cleared or reset, causing all of your content to be “new” again.

    A second solution would require user’s to be logged in. Having a user log into the site sets up a very easy way to track, and a non-volatile way to show them new content without the worry of them seeing old stuff marked as “new”. Plus you could easily email registered users when new content is available.

    Let me know which path you are planning to stroll down and I can offer a little more insight.

    Thread Starter ThomasK702

    (@thomask702)

    Thanks for your reply!

    We are going to require users to be logged in to view most of the content, so your second solution probably fits our needs the best. We plan on releasing new content every day (Monday-Friday), and sending out an email blast/newsletter.

    Thanks for your insight!

    -Thomas

    wpismypuppet

    (@wordpressismypuppet)

    Great!

    What I would do, if I were your programmer, would be to create a “links” table (or other such appropriately named table) in my WordPress installation. Then, in my header.php file I would run a SQL query as the very first thing to update my table with the user’s ID (of the logged in user), and the ID of the page/post/whatever they are currently looking at.

    I would probably keep the ID’s of the pages and the user ID as one row instead of separate rows, to keep the database small, but that’s just me an I’m not a database engineer. This way the table will only be the same number of rows as there are registered users.

    You could probably get away with two columns, one for the user’s ID and another for a comma separated list of page/post/whatever ids. Example:

    userID    postIDs
    21        1,2,32,45

    If, however, you wanted to record the date a page was first/last access, you’ll need to put each entry in it’s own row. Example:

    userID    postID    dateFirstViewed    dateLastViewed
    21        1         12345678912        53627848956
    21        2         12345678332        53627848956
    21        32        12345678912        53627848956

    Note that the same userID is used for all three entries to indicate this user visited these three pages/posts/whatever. Also note that the dates are timestamps, not actual dates. Better to store timestamps in a database then something like 8/2/13 4:32pm.

    So first, my function would update my table, then my function would update a new session variable to contain all of the information we just put into the database. This way I can reference the session variable to notify the user of where they have already been on my site without taxing the server by constantly querying the database. Looping through one variable 10 times is way easier than querying a database 10 times.

    Using for loops, if/else statements, or whatever other means I need, I could add class names to links, make “new” or “old” content tags, or whatever other creative way to show distinctions in the content.

    I’m sure there are plenty of other ways to do this, and some more efficient than mine, but this is off the top of my head without too much thought and time put in. This should at least get your programmer started in the right direction.

    Thread Starter ThomasK702

    (@thomask702)

    Thanks a tonne for the great response. I will get him this information as soon as he gets back so we can start working on it.

    Happy Hunting

    -Thomas

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dynamic "New Content" Label on Menu Items (posts)?’ is closed to new replies.