TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 03:23:57 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 70
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 99
  • Total: 99

[Block] Local Weather

Started by darkorical, March 19, 2009, 08:49:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dry3210

And I made it visible after hiding it for about an hour and now its working and good for the moment.

Weird. 

Awesome though so hopefully it'll keep working this time

wilsy

I'm using this block in a slightly different way on two of my sites - thanks for the share ;)

sandmannd

What type of code do I put this in as? I've used PHP, java script and HTML and none of those work.  :o

dry3210

Quote from: sandmannd on April 28, 2009, 02:11:07 AM
What type of code do I put this in as? I've used PHP, java script and HTML and none of those work.  :o

PHP block


error_reporting(0);
global $ID_MEMBER, $context,$memberContext;
loadMemberData($ID_MEMBER);
loadMemberContext($ID_MEMBER);
if($memberContext[$ID_MEMBER]['location'] == ""){echo 'If you enter your City and State on your profile this block will show you your local weather.';}
else{
$xmlDoc = new DOMDocument();
$xmlDoc->load('http://www.google.com/ig/api?weather='.$memberContext[$ID_MEMBER]['location'].'');
$params=$xmlDoc->getElementsByTagName('weather');       
$params2 = $params->item($k)->getElementsByTagName('current_conditions') ;
     
$i=0; // values is used to iterate categories
$params3 = $params2->item($i)->getElementsByTagName('condition');
$params4 = $params2->item($i)->getElementsByTagName('temp_f');
$params5 = $params2->item($i)->getElementsByTagName('humidity');
$params6 = $params2->item($i)->getElementsByTagName('icon');
$params7 = $params2->item($i)->getElementsByTagName('wind_condition');
              echo '
<table>
    <tr>
<td rowspan="2" align="center" valign="center"><img src="http://www.google.com/ig'.$params6->item($j)->getAttribute('data').'"></td>
<td>'.$params3->item($j)->getAttribute('data').'</td>
</tr>
<tr>
<td>'.$params4->item($j)->getAttribute('data').'Ã,°F</td>
</tr>
<tr>
<td colspan="2">'.$params5->item($j)->getAttribute('data').'</td>
</tr>
<tr>
<td colspan="2">'.$params7->item($j)->getAttribute('data').'</td>
</tr>
</table>';
}


I think he added a line at the beginning or end that you don't need.  I forget. 

sandmannd

Nope, that doesn't get it to work for me either.

ZarPrime

#15
I don't know why it isn't working for you.  Are you using the code in the fourth post in this topic?

It works fine for me except that the cloudy.png link is broken.  You have to make sure you have put a location into your Forum Profile Information.  And it has to be a reasonable location.  LA won't work but Los Angeles, CA probably will.

One reason I won't use it though is because it add 6 seconds to my page creation time.

ZarPrime

stigmartyr

So I noticed that the google xml feed already has the forecast in it, but the PHP block isn't calling it out?

Is there a way to include that forecast or at least a link to it?  I like the block and I'm using it on my site, just think it needs forecasting to be truly useful.

darkorical

Quote from: Ã,§tigmartyr on May 01, 2009, 09:25:07 AM
So I noticed that the google xml feed already has the forecast in it, but the PHP block isn't calling it out?

Is there a way to include that forecast or at least a link to it?  I like the block and I'm using it on my site, just think it needs forecasting to be truly useful.

yea there is a way
Step 1. Expand script to return the results of the forecast
Step 2. Embed new script into custom page
Step 3. Add link to forecast page at bottom of block

When I get a chance Ill work on step 1 but step 2 and 3 will be up to end user (Ill offer assistance tho)

stigmartyr

Quote from: darkorical on May 13, 2009, 10:14:47 PM
Quote from: Ã,§tigmartyr on May 01, 2009, 09:25:07 AM
So I noticed that the google xml feed already has the forecast in it, but the PHP block isn't calling it out?

Is there a way to include that forecast or at least a link to it?  I like the block and I'm using it on my site, just think it needs forecasting to be truly useful.

yea there is a way
Step 1. Expand script to return the results of the forecast
Step 2. Embed new script into custom page
Step 3. Add link to forecast page at bottom of block

When I get a chance Ill work on step 1 but step 2 and 3 will be up to end user (Ill offer assistance tho)

Sweet - I'd be HAPPY to do steps 2 and 3 :D  You're the man.  Thanks for helping out with this.