TinyPortal
Development => Resources => Topic started by: darkorical on March 19, 2009, 02:59:46 PM
Im working on a block that I wish to reference the users location information from their profile
I know I have it entered in my profile
and I tried this simple line of code
global $context, $user_info;
echo 'Hey '.$context['user']['name'].'. How are things in '.$context['user']['location'].' today?';
Hey Dan. How are things in today?
can someone tell me what I'm doing wrong
What have you entered in your profile? Exactly what code have you added to the profile in order to save the person's location?
I didn't add anything its there by default im just trying to access it from the front page
Oh, yeah. There is a location in the profile. :) I got confused. :uglystupid2:
Try using $user_info['location'].
Or maybe add $memberContext and $ID_MEMBER to your global statement and use
$memberContext[$ID_MEMBER]['location']
I usually just try a bunch of different things until I find one that works. :)
nada
global $context, $user_info, $memberContext, $ID_MEMBER;
echo 'Hey '.$context['user']['name'].'. How are things in '.$user_info['location'].' / '.$memberContext[$ID_MEMBER]['location'].' today?';yeilds
QuoteHey Dan. How are things in / today?
Well, heck! :)
Okay. One more thing to try.
global $ID_MEMBER, $context,$memberContext;
loadMemberData($ID_MEMBER);
loadMemberContext($ID_MEMBER);
echo 'Hey '.$context['user']['name'].'. How are things in '.$memberContext[$ID_MEMBER]['location'].' today?';
I did test it this time. :)
Thank you Very much!
Here is the block I was trying to build
Local weather
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>';
}
Cool! (Or maybe partly cloudy. ;) )