PDA

View Full Version : php templates


WeatherImages
Sun 28th Jan '01, 8:17pm
Please excuse my ignorance with php. To be honest, I didn't know the first thing about php until I installed vbulletin. So this is a big time learning process for me. Hoping someone might be able to explain something to me...
I have a weather site. I'd like to add some new radar images to my site and the way I've done this before is create an html file for each new image I add. Is it possible for me to make one php template for all the new images I want to add? Then when someone selects a particular radar image they want to view, they will view the template with the radar image they selected. Then if I ever wanted to make any changes to the layout or change links I could update one template and be done. Can this be done with php? And if so, can someone explain it to me in pseudo code and maybe a few syntax pointers? Thanks so much!
-Mark

Krucifyx
Tue 30th Jan '01, 12:26am
Its VERY easy.

Lets say the radar image is called march16.jpg

You would link to the file as follows:

<a href="script.php?var=value">Link</a>

Now for the script itself

The only thing it really needs is the following:

<img src="/path/to/images/<?=$var?>">

In the above instance, the value specified in var (from the link) will be what is placed as the image. But if you want to change the name of the variable, do so in the link, so:

<a href="script.php?image=radar.jpg">Link</a>
You would access "radar.jpg" using the variable $image

WeatherImages
Tue 30th Jan '01, 12:42am
Thanks for posting the help Krucifyx. I have a couple more questions when you or anyone else who reads this has the time. When you posted this code: <img src="/path/to/images/<?=$var?>"> I assume that has to reside on my server? Is there any way I could have this image come from another website alltogether?
vBulletin uses things like $timezone and $lastpost and stuff. Is there any way I could make $raleigh or $seattle and put that into the link? And then somewhere somehow tell the server to load a certain image for $raleigh that doesn't reside on my server?

s.molinari
Sun 4th Feb '01, 6:27am
Instead of passing just the file name pass the whole address.

Link in your select page would look like this:

<a href="script.php?var=value">Link</a>

The variable 'value' would be a complete internet address such as:

http://www.a-weather-site.com/images/march/16.jpg

Then, in your script.php file you would have:

<img src="<?$var?>">

Hope I could help.

Scott