Hello.
I'm trying to insert a custom google map on the user profile (profile.about.php).
Here is a user profile for you to test:
2015.iyengar.com.br/jonathan
My code so far is something like that:
<?php
$cuser = CFactory::getUser();
$addr = $cuser->getInfo('FIELD_ADDRESS');
$cidade = $cuser->getInfo('FIELD_CITY');
$estado = $cuser->getInfo('FIELD_STATE');
$pais = $cuser->getInfo('FIELD_COUNTRY');
$urlok = $addr . $cidade . $estado . $pais;
$urlok = preg_replace('/\s+/', '+', $urlok);
?>
<iframe
width="100%"
height="400"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/search?key=AIzaSyAJ5mZi1gJYnMOQwVvrbDt4PUgzhVKO-bc&q=<?php echo $urlok; ?>" allowfullscreen>
</iframe>
<?php
$cuser = CFactory::getUser();
$data = $cuser->getInfo('FIELD_ADDRESS');
echo $data;
?>
Hi,
That code should be fine, so what is the problem? can you provide me more detail information plus the screenshoot, please?
thank you!
Hi Dimas.
OK, your answer made me think, then I checked if it was working when I'm logged in, and it is OK.
But as this website need to have 100% of the profile public, can you please tell me how to make this fields visible publicly?
I mean, any field that I can retrieve with your default code from the documentation:
$cuser = CFactory::getUser();
$data = $cuser->getInfo('FIELD_GENDER');
echo $data;
Hi,
Ok, please you open this file /components/com_community/templates/jomsocial/people.browse.php, add this code :
<?php echo JText::_($row->user->getInfo('FIELD_GENDER'))."<br>" ?>
<a href="<?php echo $row->profileLink; ?>"><h4 class="joms-text--username"><?php echo $row->user->getDisplayName(); ?></h4></a>
Hi Dimas.
That worked for the people.browse.php. Thank you!
But profile.about.php still doesn't work with my map instance:
<?php
$addr = $row->user->getInfo('FIELD_ADDRESS');
$cidade = $row->user->getInfo('FIELD_CITY');
$estado = $row->user->getInfo('FIELD_STATE');
$urlok = $addr . "+" . $cidade . "+" . $estado ;
?>
<iframe
width="100%"
height="400"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/search?key=AIzaSyAJ5mZi1gJYnMOQwVvrbDt4PUgzhVKO-bc&q=<?php echo $urlok; ?>" allowfullscreen>
</iframe>
Ops, here is the correct code:
<?php
$cuser = CFactory::getUser();
$addr = $cuser->getInfo('FIELD_ADDRESS');
$cidade = $cuser->getInfo('FIELD_CITY');
$estado = $cuser->getInfo('FIELD_STATE');
$urlok = $addr . "+" . $cidade . "+" . $estado ;
$urlok = preg_replace('/\s+/', '+', $urlok);
?>
<iframe
width="100%"
height="400"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/search?key=AIzaSyAJ5mZi1gJYnMOQwVvrbDt4PUgzhVKO-bc&q=<?php echo $urlok; ?>" allowfullscreen>
</iframe>
Clarification on the last post above:
"here is the correct non working code"
Hi Dimas.
You are logged in. It should also work while you are logged out.
Cheers!
I looked at the docs again, and found that replacing
$cuser = CFactory::getUser();
$cuser = CFactory::getRequestUser();
<?php
$cuser = CFactory::getRequestUser();
$addr = $cuser->getInfo('FIELD_ADDRESS');
$cidade = $cuser->getInfo('FIELD_CITY');
$estado = $cuser->getInfo('FIELD_STATE');
$urlok = $addr . "+" . $cidade . "+" . $estado ;
$urlok = str_replace(',', '', $urlok);
$urlok = str_replace('.', '', $urlok);
$urlok = str_replace('-', '', $urlok);
$urlok = str_replace(';', '', $urlok);
$urlok = str_replace(' ', '+', $urlok);
?>
<iframe
width="100%"
height="400"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/search?key=AIzaSyAJ5mZi1gJYnMOQwVvrbDt4PUgzhVKO-bc&q=<?php echo $urlok; ?>" allowfullscreen>
</iframe>