PDA

View Full Version : Resolved iframe change source everyday (365 days)?



tc2010
05-10-2014, 09:31 PM
So, basically, I am making a custom "Bible in a Year" type deal for my church website. I found this script to change everyday of the month, http://www.dynamicdrive.com/dynamicindex17/dowiframe2.htm, but I need the whole year. If this is possible in php include, I can live with that too, or maybe you have an easier way I can accomplish this painstaking task.

jscheuer1
05-11-2014, 01:55 AM
The painstaking part is transcribing/organizing the verses. PHP would be easy to use to display one each day for a year. So would javascript, but you will be more accessible using PHP, and of the two, it's a little easier for what you're talking about:



<?php
$doy = date('z');
while (strlen($doy) < 3){
$doy = '0' . $doy;
}
include 'verse' . $doy . '.txt';
?>

This will grab from the current folder, verse000.txt through verse365.txt (verse365.txt will only be displayed on Dec 31st of leap years), depending upon which day of the year it is. Today it would be verse129.txt (May 10th).

So, as I say, the painstaking part is transcribing and organizing all those files.

Good luck!

Let me know if you have any questions.

tc2010
05-11-2014, 02:08 AM
That sounds like a good approach, my only concern is styling. I was wanting to do some HTML styling (bold text, backgrounds, etc.), will this be possible using .txt?

jscheuer1
05-11-2014, 02:45 AM
There are lots of ways that could be done. You can use .htm or .html, which is what I would recommend. (You can just use .txt and have tags on there, but it's confusing.) That along with fairly consistent markup within the included files so that one stylesheet could be used to style whichever one of them happens to be up that day:


<div id="verse">
<?php
$doy = date('z');
while (strlen($doy) < 3){
$doy = '0' . $doy;
}
include 'verse' . $doy . '.htm';
?>
</div>

Then you could use just headers, spans, ps and divs on the external files and have rules, for example:


#verse h2 {color: blue;}

on or linked to the main page. When a file is included, it's markup will follow those rules.

When including htm, do not put DOCTYPE, head, body on the external file. Those can be used only once and should already be on the page that is including these other pages.

tc2010
05-11-2014, 02:53 AM
Perfect! Just tried it, and it seems to do exactly what I want! Thanks for all the help!!