Click to See Complete Forum and Search --> : Making Updated Links show *New*


lemonjenny
04-21-2003, 07:09 PM
Hi everyone! I'm new here. :)

I have a question that I just can't seem to figure out. I have a website where there are links to other pages within the website, all with SSI blogger weblogs. I have a link to every page on the main page, and want the links to have an * after them or soemthing when they've been recently updated. I don't have ASP, so I was hoping there was another way to do this. Anyone have any suggestions/advice? The website is www.macletter.com

Thanks!

Jona
04-21-2003, 07:33 PM
I doubt this can be done client-side. So you should use a server-side language. If you don't have ASP, do you have PHP or Perl?

If you can't use a server-side language, you'll have to edit it manually.

lemonjenny
04-22-2003, 12:05 AM
My webserver does have PHP and Perl. I just don't know how to do it. Any help? How would I use php or perl to add the "new" to my links?

Jona
04-22-2003, 12:29 AM
...Hmmmm...... Well, I know it will take a server-side language, but I don't know how to do it. I'll look around to see if I can figure it out for you. Try http://php.net/ or http://perldoc.com/ for more information--see if you can figure it out. ;)

lemonjenny
04-22-2003, 01:09 AM
I checked those sites and have had no luck. I think I'm not even sure what to look for! Please help? :)

Jona
04-22-2003, 12:33 PM
I promise to work on it... As soon as I can get my testing server up. :(

AdamGundry
04-22-2003, 12:54 PM
Untested PHP code:

<?
$filename = "page.html";
$newtime = 1;

if ((time() - filemtime()) < ($newtime * 86400)) print "*";
?>


This should print an asterisk (*) if the file given has been modified in the last 24 hours (1 day). I hope.

Adam

Jona
04-22-2003, 01:42 PM
Adam, now all we need is to get the information about an individual (or better yet, an array) of the links and add an asterisk to the end of whichever ones have been updated recently. I believe linkinfo() gets all information from a link--question: how is this used to subtract time? :)

AdamGundry
04-22-2003, 03:49 PM
Okay, here's come more PHP code (tested, this time):

<?
$RecentUpdateDays = 1;
$links = array (
"page1.html" => "Page 1",
"page2.html" => "Page 2",
"page3.html" => "Page 3"
);

foreach ($links as $link => $title){
if ((time() - filemtime($link)) < ($RecentUpdateDays * 86400)){
print "<br><a href=\"$link\">$title *</a>\n";
} else {
print "<br><a href=\"$link\">$title</a>\n";
}
}
?>


Change $RecentUpdateDays to adjust the number of days the asterisk appears for, and adjust the links and titles using the associative array.

Adam

Jona
04-22-2003, 03:57 PM
Way to go, Adam! Thanks, that helped me learn some more too! (I just started learning PHP about a week ago... :rolleyes: )

lemonjenny
04-22-2003, 08:58 PM
Adam, thank you very much for the code! Forgive me, I am still just a child when it comes to PHP, so I need some more help. I am building this site in Dreamweaver. I already have the links there in my normal HTML code. Where do I put this PHP code? Does it replace the HTML links I have? Is it part of those? :rolleyes:

AdamGundry
04-23-2003, 03:52 AM
Yes, replace the links with the PHP code, because it will generate links anyway. You'll also need to name your file *.php or *.phtml so it is read correctly by PHP.

Adam