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

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 08:22:15 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,104
  • Total Topics: 21,212
  • Online today: 152
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 160
  • Total: 161
  • tino

User Location

Started by darkorical, March 19, 2009, 02:59:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darkorical

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

JPDeni

What have you entered in your profile? Exactly what code have you added to the profile in order to save the person's location?

darkorical

I didn't add anything its there by default im just trying to access it from the front page

JPDeni

#3
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. :)

darkorical

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?

JPDeni

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. :)

darkorical

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>';
}

JPDeni

Cool! (Or maybe partly cloudy. ;) )