By Fagault Eric on Tuesday, 08 August 2017
Posted in General
Replies 4
Likes 0
Views 203
Votes 0
Hello,
In a dashboard that I prepare, I need to retrieve the information "RELATIONSHIP"

When I do: $ profile-> getFieldValue ('RELATIONSHIP')

This displays (For example)
{ "Target": [ "984"], "targetRelation": [ "984"], "type": "relationship"}

I would like to display it correctly.

I thought of directly drawing this information from the table "social_relationship_status", but jp teach that I complicate and that there is certainly a much simpler way.

Also when I do: $ profile-> getFieldValue ('BIRTHDAY') ;, I would like to display that day and month, how do I format this display?

Best regards.

Eric

{ "Target": [ "984"], "targetRelation": [ "984"], "type": "relationship"}

This value is primarily used for php codes. You can run something like this to get the target,

[gist]
<?php
$data = json_decode($profile->getFieldValue('RELATIONSHIP'));
$user = ES::user($data->target);

echo "In a " . $data->type . " with " . $user->getName();
?>
[/gist]



Also when I do: $ profile-> getFieldValue ('BIRTHDAY') ;, I would like to display that day and month, how do I format this display?

You need to look at the output and retrieve the data accordingly.
·
Wednesday, 09 August 2017 01:29
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,
Thank you.
As you suggest, I did:
$ Data = json_decode ($ profile-> getFieldValue ('RELATIONSHIP'));
$ User2 = ES :: user ($ data-> target);
Echo "In a". $ Data-> type. "With". $ User2-> getName ();

"$ Data-> type" does not display the type, but displays "relationship"
Then
$ User2-> getName (); Causes an error.


I would have to get the value of the language file to display the correct "type"?

Can you tell me which file can display the profile information.
I will restore in this file how this is done.

Best regards.
Eric
·
Wednesday, 09 August 2017 05:17
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Eric,

Perhaps you can try use the code below see how it goes?

$db = ES::db();
$user = ES::user();
$query = 'SELECT * FROM `#__social_relationship_status` WHERE `actor` ' . ' = ' . $db->Quote($user->id);
$db->setQuery($query);
$result = $db->loadObject();
echo $result->type;
·
Wednesday, 09 August 2017 16:25
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post