Solved

Showing user an image dynamically for a day?

Posted on 2004-08-10
6
135 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
ID: 11767966

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
ID: 11768205
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
ID: 11768239

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:Westside2004
ID: 11768397
HI,

Will try it now..

What is the "h"?
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11768471
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
ID: 11779314
Ok..

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

Thanks

-Westside
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

14 Experts available now in Live!

Get 1:1 Help Now