Forums
This topic is locked
How to do Archiving?
29 Apr 2003 12:09:49 James Lee posted:
Dear all,Wish to ask anyone knows how to create an archiving system in Dreamweaver that automatically archives news when the news is 10 days old. If news that are 20 days old, then another batch? I know somehow or rather, I have to store it in a database. But have anyone done it before so that can enlighten me.
Thanks for reading this!
Replies
Replied 29 Apr 2003 17:33:13
29 Apr 2003 17:33:13 Vince Baker replied:
Not sure if this is the solution you are looking for but couldnt you just show news items that are less than 10 days from today?
That way you would keep all of your records but the user will only see those from the past ten days....
you could use the datediff function in sql to do this.
If this is what you want let me know and I will give you some sample code on using datadiff..
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
That way you would keep all of your records but the user will only see those from the past ten days....
you could use the datediff function in sql to do this.
If this is what you want let me know and I will give you some sample code on using datadiff..
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 29 Apr 2003 23:06:26
29 Apr 2003 23:06:26 Dennis van Galen replied:
Yah, use the datediff...hmmm, you use ColdFusion right ?
consider if you will, this:
User enters news item, types in headline, catchline for frontpage and main article...Then he sets a option of how long the news item should be displayed.
User presses submit and it is shot into your database, your news page checks all these news items for a status flag, this flag is either 1 or 0 and is set to 1 when the news item is created. The news page only returns records where status is 1...
Now here is the trick, you create a simple ColdFusion page with just the following code:
<pre id=code><font face=courier size=2 id=code>
<cfquery name="newsArchiver" datasource="DSN HERE">
UPDATE NewsItems
SET ActiveNews = 0
WHERE ActiveNews = 1 AND NewsShowLength < DATEDIFF(day, NewsCreationDate, getDate())
</cfquery>
</font id=code></pre id=code>
<b>NewsCreationDate</b> is a field that is filled with getDate() when the article is created.
<b>NewsShowLength</b> is a field holding the value the user wants the article to be displayed.
You then schedule this page (in the CF administrator) to run each morning at 2am or something and voila, you are all set.
HTH a little.
with kind regards,
Dennis van Galen
DMXzone Manager
FAQ, Tutorial and Extension Manager
Studio MX / CFMX PRO / SQL 2000 / NT4 AND win2kPRO / IIS5
Edited by - djvgalen on 29 Apr 2003 23:12:48
consider if you will, this:
User enters news item, types in headline, catchline for frontpage and main article...Then he sets a option of how long the news item should be displayed.
User presses submit and it is shot into your database, your news page checks all these news items for a status flag, this flag is either 1 or 0 and is set to 1 when the news item is created. The news page only returns records where status is 1...
Now here is the trick, you create a simple ColdFusion page with just the following code:
<pre id=code><font face=courier size=2 id=code>
<cfquery name="newsArchiver" datasource="DSN HERE">
UPDATE NewsItems
SET ActiveNews = 0
WHERE ActiveNews = 1 AND NewsShowLength < DATEDIFF(day, NewsCreationDate, getDate())
</cfquery>
</font id=code></pre id=code>
<b>NewsCreationDate</b> is a field that is filled with getDate() when the article is created.
<b>NewsShowLength</b> is a field holding the value the user wants the article to be displayed.
You then schedule this page (in the CF administrator) to run each morning at 2am or something and voila, you are all set.
HTH a little.
with kind regards,
Dennis van Galen
DMXzone Manager
FAQ, Tutorial and Extension Manager
Studio MX / CFMX PRO / SQL 2000 / NT4 AND win2kPRO / IIS5
Edited by - djvgalen on 29 Apr 2003 23:12:48
Replied 30 Apr 2003 08:57:44
30 Apr 2003 08:57:44 Vince Baker replied:
Obviously I didnt understand the requirement, thanks for the overly sarcastic response....
Nothing like the manager of the site being supportive of people trying to aid others.....
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Nothing like the manager of the site being supportive of people trying to aid others.....
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Apr 2003 21:44:16
30 Apr 2003 21:44:16 Dennis van Galen replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Obviously I didnt understand the requirement, thanks for the overly sarcastic response....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
My post was not meant as sarcastic although I guess it could be interpreted as such.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Nothing like the manager of the site being supportive of people trying to aid others.....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I very much support people trying to aid others, that is what this site is all about, I remember when I was the one asking the questions on this same website.
The truth is, I saw this question and remembered another question from James concerning ColdFusion so I offered a straight solution for his specific situation. I guess I overdid it, my apologies for that.
Dennis
Obviously I didnt understand the requirement, thanks for the overly sarcastic response....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
My post was not meant as sarcastic although I guess it could be interpreted as such.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Nothing like the manager of the site being supportive of people trying to aid others.....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I very much support people trying to aid others, that is what this site is all about, I remember when I was the one asking the questions on this same website.
The truth is, I saw this question and remembered another question from James concerning ColdFusion so I offered a straight solution for his specific situation. I guess I overdid it, my apologies for that.
Dennis
Replied 01 May 2003 09:13:54
01 May 2003 09:13:54 Vince Baker replied:
Thanks Dennis
I appreciate your comments.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
I appreciate your comments.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 02 May 2003 10:56:13
02 May 2003 10:56:13 James Lee replied:
Hello all,
Thanks for your prompt reply. I didn't know there is a SQL function call DateDiff. But, why do you set ActiveNews to 0 when you already satisfied the condition?
And can I make it in such a way that when the message is 10 days older, The news article will be allocated to a different link? For example, within 10 days, I link it to 10days.asp and more than that, then it automatically goes to 20days.asp. By the way, I am surprised you still can remember me posing the Coldfusion question, but I am currently using ASP now for this project <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Thanks for reading this!
Thanks for your prompt reply. I didn't know there is a SQL function call DateDiff. But, why do you set ActiveNews to 0 when you already satisfied the condition?
And can I make it in such a way that when the message is 10 days older, The news article will be allocated to a different link? For example, within 10 days, I link it to 10days.asp and more than that, then it automatically goes to 20days.asp. By the way, I am surprised you still can remember me posing the Coldfusion question, but I am currently using ASP now for this project <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Thanks for reading this!
Replied 05 May 2003 18:46:07
05 May 2003 18:46:07 Dennis van Galen replied:
First of all, excuse my late response, I was away for a few days.
I set the ActiveNews to 0 so that the news page does not get that particular item, you can then have your older then 10 days page filter the news items like this:
WHERE ActiveNews = 0 AND DATEDIFF(day, NewsCreationDate, getDate()) < 20
For 20 days (and older) news you simply tell the 20 days page to filter like:
WHERE ActiveNews = 0 AND DATEDIFF(day, NewsCreationDate, getDate()) > 20
And your normal news page simple filters like:
WHERE ActiveNews = 1
Offcourse you could leave out the ActiveNews = 0 since after your updates every item that is older then 10 days is automatically 0, but for 10 days you would need to add another datediff > 10 and this just looks nicer and it gives 2 uses for the single ActiveNews field.
HTH.
with kind regards,
Dennis van Galen
DMXzone Manager
FAQ, Tutorial and Extension Manager
Studio MX / CFMX PRO / SQL 2000 / NT4 AND win2kPRO / IIS5
I set the ActiveNews to 0 so that the news page does not get that particular item, you can then have your older then 10 days page filter the news items like this:
WHERE ActiveNews = 0 AND DATEDIFF(day, NewsCreationDate, getDate()) < 20
For 20 days (and older) news you simply tell the 20 days page to filter like:
WHERE ActiveNews = 0 AND DATEDIFF(day, NewsCreationDate, getDate()) > 20
And your normal news page simple filters like:
WHERE ActiveNews = 1
Offcourse you could leave out the ActiveNews = 0 since after your updates every item that is older then 10 days is automatically 0, but for 10 days you would need to add another datediff > 10 and this just looks nicer and it gives 2 uses for the single ActiveNews field.
HTH.
with kind regards,
Dennis van Galen
DMXzone Manager
FAQ, Tutorial and Extension Manager
Studio MX / CFMX PRO / SQL 2000 / NT4 AND win2kPRO / IIS5