Solved

Showing user an image dynamically for a day?

Posted on 2004-08-10
6
134 Views
Last Modified: 2013-12-24
Hi,

I wanted to see if someone can help with this issue.

I wanted to add this small feature for our site.  Basically when a user creates a new document in our web based app, we show the user a list of the documents associated with their account in a nice html table.  Their documents are listed as hyperlinks.

I want to display a simple image on my page that has the words "new" on it next to the hyperlink if the document was created "today".  So for the whole day the user would see the *New* image next to the hyperlink.

The next day when the user logs in, the new image would be gone as it would be the next day.

How can I accomplish this?  Does it involve client variables or would it be done through a cookie?  If user does not accept cookies, what alternatives are there?  It is my understanding that client variables compare the information from a db or a registry to a cookie on the users machine so if the user does not have cookies enabled, what does the client var in our db compare itself to???

Thanks,

West



0
Comment
Question by:Westside2004
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:Seth_Bienek
Comment Utility

Hey West,

All you need is the age of the document.

Wether it's a file or a record in a database, there should be a date associated with it's creation.  Use that date to determine wether the 'new' graphic gets displayed or not:

<cfif datediff(userdocument.date_added, now()) LTE 0><img src="/images/new.gif"></cfif>

Something like that.

Regards,

Seth
0
 
LVL 1

Author Comment

by:Westside2004
Comment Utility
Yes, that makes sense..

Will try what you gave me..

I am basically looking to show the image if the document is 6 hours old or less, if so, mark it new by showing the new img

Otherwise, don't show any image at all..

Thanks

-West
0
 
LVL 5

Accepted Solution

by:
Seth_Bienek earned 125 total points
Comment Utility

I was just looking at the code I posted.  I don't know what I was thinking about, but the syntax is wrong.

Should have been:

<cfif datediff("h", userdocument.date_added, now()) GTE 6><img src="/images/new.gif"></cfif>

Regards,

Seth
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:Westside2004
Comment Utility
HI,

Will try it now..

What is the "h"?
0
 
LVL 21

Expert Comment

by:pinaldave
Comment Utility
Hi Westside2004,
seth has good suggestion. h stands for hour. As you are looking for six hours difference.

Regards,
---Pinal
0
 
LVL 1

Author Comment

by:Westside2004
Comment Utility
Ok..

I thought that... but wanted to just make sure...

Thanks

-Westside
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now