Jonathan Drucker <jo...@ya...> writes:
> Hey everyone. I am having trouble getting phpWeather to show on my
> site. I am not quite sure how to get it to be implemented.
First, you have to decide where you would like to show it, and if you
want to show the big text report. When you've found the right spot in
your HTML code, then it's mostly a matter of inserting PHP code like
this:
<?php
require('path/to/phpweather.php');
require(PHPWEATHER_BASE_DIR . 'pw_utilities.php');
require(PHPWEATHER_BASE_DIR . '/output/pw_text_en.php');
include(PHPWEATHER_BASE_DIR . '/output/pw_images.php');
$weather = new phpweather();
$text = new pw_text_en($weather);
$icons = new pw_images($weather);
echo "<blockquote>\n";
$text->print_pretty()
echo "</blockquote>\n";
echo "<p>The matching icons are:</p>\n";
echo "<blockquote>\n" .
'<img src="' . $icons->get_sky_image() .
'" height="50" width="80" border="1" alt="Current weather in ' .
$weather->get_location() . '" /> ' .
'<img src="' . $icons->get_winddir_image() .
'" height="40" width="40" border="1" alt="Current wind in ' .
$weather->get_location() . '" /> ' .
'<img src="' . $icons->get_temp_image() .
'" height="50" width="20" border="1" alt="Current temperature in ' .
$weather->get_location() . '" />' .
"\n</blockquote>\n";
?>
The basic idea is, that you first tell PHP that you require some
PhpWeather files, then you create your $weather object. This can give
you the name of the station with $weather->get_location() and it's
used to create a $text and an $icons object. The $text object will
give you the big text report when you call the print_pretty() method:
$text->print_pretty();
In the above code I've wrapped the report in <blockquote> tags, adjust
as needed. The $icons object will give you three URLs:
$icons->get_sky_image(), $icons->get_winddir_image(), and
$icons->$icons->get_temp_image(). These URLs are used in <img> tags
$icons->$icons->as
you would expect.
If you want the more complex setup with forms for choosing countries,
languages etc, then take another look at index.php. It collects output
in the $output variable and finally prints it out when everything's
ready. You'll probably want to skip the first part that adds to
$output and then adjust the part that starts after if (!empty($icao)).
> When i run the test page, everything works just fine.
Great, then we know that PhpWeather works at your site.
> I am very new to php, so try to keep it simple :-)
--
Martin Geisler My GnuPG Key: 0xF7F6B57B
See http://gimpster.com/ and http://phpweather.net/ for:
PHP Weather: Shows the current weather on your webpage and
PHP Shell: A telnet-connection (almost :-) in a PHP page.
Join Freenet: http://gimpster.com/downloads/freenet/
|