picture of the day using front page?

  • Thread starter MD WebsUnlimited.com
  • Start date
M

MD WebsUnlimited.com

Hi Peter,

You'll need to use ASP / PHP / CGI to accomplish that. J-Bots offers a
component but the list of pictures is contained in the web page itself.

Under the ASP category would be using the Database Results Wizard to query a
database of image links then displaying the image.
 
J

Jim Buyens

Peter A. Berger Jr. said:
Hi all. FP newbie here. Was wondering if theres a way to get an automated
picture of the day generator for a page that chooses pics randomly out of a
specified path?
I am hoping to stop having to edit my default page each day to manually
change the picture. Any help/411 would be great. Thanks. :)

You could program this in JavaScript to run on the browser, or in a
server-based environment such as ASP, ASP.NET, or PHP.

I'd post some code, but the concept of a random picture of the day has me
all verklempt. Do you want to:

o Randomly choose a picture each time a visitor requests the page?
o Randomly choose a picture in such a way that all vistors during a
24-hour interval get the same picture?
o Prespecify a different picture for each day of the week?
o Prespecify a different picture for each day of the month?

Also, do you care whether the day begins and ends at server midnight, or
at browser midnight?

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
P

Peter A. Berger Jr.

I don't really want to get into scripting CGI/PHP (I'm a hardware dude...not
a programmer) I'm not trying to get thaaat fancy...I would just like to have
FP randomly choose a picture from a picture depot each day (24hrs) and have
it change at 0000hrs ET server time. Prefferably some small picture
dimensions to have the default page load quickly...but if that's not
possible the original picture size/resolution will work fine. Thanks for the
tips/help.

P.S: I don't use the newsgroups often, but I do find them an invaluable
resource that keeps people interested in these products. They are great for
quick help. Thanks.
 
P

Peter A. Berger Jr.

Hi all. FP newbie here. Was wondering if theres a way to get an automated
picture of the day generator for a page that chooses pics randomly out of a
specified path?
I am hoping to stop having to edit my default page each day to manually
change the picture. Any help/411 would be great. Thanks. :)
 
J

Jim Buyens

Peter A. Berger Jr. said:
I don't really want to get into scripting CGI/PHP (I'm a hardware dude...not
a programmer) I'm not trying to get thaaat fancy...I would just like to have
FP randomly choose a picture from a picture depot each day (24hrs) and have
it change at 0000hrs ET server time. Preferably some small picture
dimensions to have the default page load quickly...but if that's not
possible the original picture size/resolution will work fine. Thanks for the
tips/help.

This script is a little awkward, but try inserting it where you want
each day's chosen picture to appear.

<script>
pics = new Array("sample10.jpg", "sample11.jpg", "sample12.jpg");
curDate = new Date();
curDate.setMinutes(curDate.getMinutes() + curDate.getTimezoneOffset()
- 300);
curDay = curDate.getDay();
picNum = curDay % pics.length;
document.write("<img src='photos/" + pics[picNum] + "'>");
</script>

Modify the list of pictures in line 2 to include the pictures you
want. There can be as few as 2 or as many as 31.

The value 300 near the end of line four specifies the number of
minutes difference between server time and GMT time. That statement
gets the number of minutes in the local time, adds the offset in
minutes from GMT to local time, and subtracts the offset in minutes
from GMT to the server's time. It then "crams" this value into the
Minutes field of the curDate object (which, up until then, contained
the current date and time). Setting the Minutes field to a negative
value or a value greater than 59 updates the day, month, and year as
necessary.

All this is dependent on the visitor having configured the time on
their computer correctly. That's a risk, but it's the best I can do
without running anything on the server.

The script chooses a date by dividing the current day of the month by
the number of pictures, and using the remainder to subscript the array
of picture names. So, if you have five pictures, they'll appear as
follows:

Day of Month Remainder Picture Number
------------ --------- -------------
1 1 2
2 2 3
3 3 4
4 4 5
5 0 1
6 1 2
7 2 3

and so forth.

Be sure to correct the path in the next-to-last line so it points to
the correct folder on your server.
P.S: I don't use the newsgroups often, but I do find them an invaluable
resource that keeps people interested in these products. They are great for
quick help. Thanks.

Good luck with your site.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
----------------------------------------------------
 
P

Peter A. Berger Jr.

J -- The code you supplied below works fine. Thanks. I had an idea though
when I was choosing the 31 images to put in my "picofday" image directory.

Would it be easier to have FP code copy a random picture from a directory
into the picofday depot each day?
where $x is a randomly chosen file.
at midnight copy d:\files\pics\$x d:\website\picofday\today.jpg

I'm not sure of this is possible. If so it would be great becuase i could
have hundreds of pics in this directory and have FP choose one randomly each
day. This way I wouldn't have to maintain and change the 31 pictures in the
picofday depot.

Thanks for your help again. :)
======================================================
Jim Buyens said:
"Peter A. Berger Jr." <[email protected]> wrote in message
I don't really want to get into scripting CGI/PHP (I'm a hardware dude...not
a programmer) I'm not trying to get thaaat fancy...I would just like to have
FP randomly choose a picture from a picture depot each day (24hrs) and have
it change at 0000hrs ET server time. Preferably some small picture
dimensions to have the default page load quickly...but if that's not
possible the original picture size/resolution will work fine. Thanks for the
tips/help.

This script is a little awkward, but try inserting it where you want
each day's chosen picture to appear.

<script>
pics = new Array("sample10.jpg", "sample11.jpg", "sample12.jpg");
curDate = new Date();
curDate.setMinutes(curDate.getMinutes() + curDate.getTimezoneOffset()
- 300);
curDay = curDate.getDay();
picNum = curDay % pics.length;
document.write("<img src='photos/" + pics[picNum] + "'>");
</script>

Modify the list of pictures in line 2 to include the pictures you
want. There can be as few as 2 or as many as 31.

The value 300 near the end of line four specifies the number of
minutes difference between server time and GMT time. That statement
gets the number of minutes in the local time, adds the offset in
minutes from GMT to local time, and subtracts the offset in minutes
from GMT to the server's time. It then "crams" this value into the
Minutes field of the curDate object (which, up until then, contained
the current date and time). Setting the Minutes field to a negative
value or a value greater than 59 updates the day, month, and year as
necessary.

All this is dependent on the visitor having configured the time on
their computer correctly. That's a risk, but it's the best I can do
without running anything on the server.

The script chooses a date by dividing the current day of the month by
the number of pictures, and using the remainder to subscript the array
of picture names. So, if you have five pictures, they'll appear as
follows:

Day of Month Remainder Picture Number
------------ --------- -------------
1 1 2
2 2 3
3 3 4
4 4 5
5 0 1
6 1 2
7 2 3

and so forth.

Be sure to correct the path in the next-to-last line so it points to
the correct folder on your server.
P.S: I don't use the newsgroups often, but I do find them an invaluable
resource that keeps people interested in these products. They are great for
quick help. Thanks.

Good luck with your site.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
----------------------------------------------------
 
J

Jim Buyens

Peter A. Berger Jr. said:
J -- The code you supplied below works fine. Thanks. I had an idea though
when I was choosing the 31 images to put in my "picofday" image directory.

Would it be easier to have FP code copy a random picture from a directory
into the picofday depot each day?
where $x is a randomly chosen file.
at midnight copy d:\files\pics\$x d:\website\picofday\today.jpg

I'm not sure of this is possible. If so it would be great becuase i could
have hundreds of pics in this directory and have FP choose one randomly each
day. This way I wouldn't have to maintain and change the 31 pictures in the
picofday depot.

Yes, you could do that, but copying files on the server would require
programming that runs on the server. And you said you didn't want to
do that.

If you've changed your mind and need some advice on how to proceed,
please post the following to this thread:

o The type of Web server (Windows, Unix, ...)
o The type of server-side programming supported (ASP, ASP.NET, PHP, ...)
o Whether you have access to the system scheduler (i.e. the AT command,
Control Panel: Scheduled Tasks, or chron).

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
P

Peter A. Berger Jr.

J -- I'm serving on:
Windows 2003 Enterprise (IIS6.0) with all the default features installed.
This machine is here at my house so I have full admin control.

If it would be too much of a burnden then please don't take too much of your
time. The solution you provided already works good. Thanks in advance.

P.S: Looks like your books are getting rave reviews in this forum. Perhaps
I'll have to check it out ;)
======================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top