Main
Index
Search
Posts
Who's
Online
Log
In

Home: Discontinued/Classic Products: Article Manager 1 Add-ons:
Today's Articles Link

 

 


Benjamin
Staff


Mar 30, 2003, 10:51 AM

Post #1 of 1 (2600 views)
Shortcut
Today's Articles Link Can't Post

Hi everyone,

Here's a little script that allows you to put a link to "Today's Articles". It's easily modifiable to retrieve a different day, but hopefully it'll get you guys started. :-)






Between your <head></head> tags of your page, put the following code:

<script language="javascript">
<!--

// the following calculates the current date
var today = new Date();
yr = today.getYear();
mon = today.getMonth();
dy = today.getDate();

// a little function to populate the values in the todays_articles form, and
// submit it.
function getTodaysArticles() {
document.todays_articles.mon.value = mon+1;
document.todays_articles.day.value = dy;
document.todays_articles.year.value = yr;
document.todays_articles.mon2.value = mon+1;
document.todays_articles.day2.value = dy;
document.todays_articles.year2.value = yr;
todays_articles.submit();
}

-->
</script>


Then, within your page, put the following:


<form method="get" name="todays_articles" action="http://www.yoursite.com/path/to/search.cgi">

<input type="hidden" name="search" value="1">
<input type="hidden" name="perpage" value="10">

<input type="hidden" name="mon" value="">
<input type="hidden" name="day" value="">
<input type="hidden" name="year" value="">
<input type="hidden" name="mon2" value="">
<input type="hidden" name="day2" value="">
<input type="hidden" name="year2" value="">

<a href="#" onclick="getTodaysArticles();">View Today's Articles</a>
</form>


Now, when you click on "View Today's Articles", it'll return only those articles for the current date.

Drawbacks / concerns: (or 'disclaimer', depending on how you look at it ;-)

- It's written in javascript. So it won't work for javascript-disabled browsers.
- It assumes that the visitor's computer has the correct time and date - it retrieves articles based on the client's computer's clock.
- It doesn't account for different time zones.

Besides that, it should work fine! I've attach a demo html file to this post.
Ben
interactivetools.com 

(This post was edited by Benjamin on Apr 2, 2003, 9:26 AM)
Attachments: getTodaysArticles.html (1.33 KB)