Forums

How to simplify the extraction of additional fields ("fields" and "fields_values tables)

jmgroud 24 Feb, 2020
English
Here is the result obtained to display the information of a user. I use the "users" table as well as the "fields" and "fields_values" tables for additional fields.
I can recover the information but I admit that it is not really simple ...

Français
Voici le résultat obtenu pour afficher les informations d'un utilisateurs. J'utilise la table "users" ainsi que les tables "fields" et "fields_values" pour les champs additionnels.
Je peux récupérer les informations mais j'avoue que ce n'est pas vraiment simple...

Array
(
[cont] => manager
[conn] => joomla-connexion
[event] => utilisateur_aff
[param_id] => 959
[Itemid] => 578
[option] => com_chronoconnectivity6
[view] => connection
)
Array
(
[utilisateur_lire] => Array
(
[log] => Array
(
[0] => SELECT `Utilisateur`.`id` AS `Utilisateur.id`, `Utilisateur`.`name` AS `Utilisateur.name`, `Utilisateur`.`username` AS `Utilisateur.username`, `Champlib`.`label` AS `Champlib.label`, `Champval`.`value` AS `Champval.value` FROM `am_users` AS `Utilisateur` LEFT JOIN `am_fields_values` AS `Champval` ON `Utilisateur`.`id` = `Champval`.`item_id` LEFT JOIN `am_fields` AS `Champlib` ON `Champval`.`field_id` = `Champlib`.`id` WHERE `Utilisateur`.`id` = '959' LIMIT 100;
)
[var] => Array
(
[0] => Array
(
[Utilisateur] => Array
(
[id] => 959
[name] => Jean-Marie GROUD
[username] => jmgroud
)

[Champlib] => Array
(
[label] => Photo
)

[Champval] => Array
(
[value] => Portrait-Jean-Marie-151x183.jpg
)
)

[1] => Array
(
[Utilisateur] => Array
(
[id] => 959
[name] => Jean-Marie GROUD
[username] => jmgroud
)

[Champlib] => Array
(
[label] => Téléphone mobile personnel
)

[Champval] => Array
(
[value] => +33 9 99 99 99 99
)
)

[2] => Array
(
[Utilisateur] => Array
(
[id] => 959
[name] => Jean-Marie GROUD
[username] => jmgroud
)

[Champlib] => Array
(
[label] => Administrateur Chrono
)

[Champval] => Array
(
[value] => 1
)
)
)
)
)

English
I would like to obtain this result directly ... Is it possible and if so, how do I configure the "Read-Data"?
The additional fields would be displayed as a field in the "users" base table.

Français
J'aimerai obtenir directement ce résultat... Est-ce possible et si oui, comment paramétrer le "Read-Data" ?
Les champs additionnels seraient affichés comme un champ de la table de base « users ».

[Utilisateur] => Array
(
[id] => 959
[name] => Jean-Marie GROUD
[username] => jmgroud
[photo] => Portrait-Jean-Marie-151x183.jpg
[telephone-mobile-personnel] => +33 9 99 99 99 99
[administrateur-chrono] => 1
)


« photo », « telephone-mobile-personnel » and « administrateur-chrono » : field « name » from « fields » table.
« Portrait-Jean-Marie-151x183.jpg », « +33 9 99 99 99 99 » and « 1 » : field « value » from « fields_values » table.
GreyHead 25 Feb, 2020
Hi jmgroud,

Joomla has a JUser class that you can use to get user info from the standard Users table including parameters stored in the table. See here

Bob
jmgroud 25 Feb, 2020
Answer
English
Thank you GreyHead for this information and this link.
Unfortunately, we are not talking here about access to additional fields (Fields + Field Groups).

For my problem ... (subject of the post), I finally created 2 different functions of type "read_data":
- The first, named "user_read" with only 1 model to read the "users" table.
- The second, named "user_chadd_lire" with 2 models:
* The first with the "fields_value" table
* The second with the "fields" table with a relationship type "One matching record, foreign key at the related table".

To display the information of a user, I use 2 different views, the first to display the basic information of the "users" table and the second view for the additional fields.
The question asked at the beginning of this post remains unanswered today but in fact, the solution of going through 2 functions satisfies me.
I therefore consider this post as validated.

Français
Merci GreyHead pour ces informations et ce lien.
Malheureusement, on ne parle pas ici de l'accès aux champs additionnels (Champs + Groupes de Champs).

Pour mon problème... (sujet du post), j'ai finalement créé 2 fonction différentes de type "read_data" :
- La première, nommé "utilisateur_lire" avec 1 seul modèle pour lire la table "users".
- La deuxième, nommée "utilisateur_chadd_lire" avec 2 modèles :
* Le premier avec la table "fields_value"
* Le deuxième avec la table "fields" avec un type de relation "One matching record, foreign key at the related table".

Pour afficher les informations d'un utilisateur, j'utilise 2 vues différentes, la première pour afficher les informations de base de la table "users" et la deuxième vue pour les champs additionnels.

La question posée au début de ce post reste aujourd'hui sans réponse mais en fait, la solution de passer par 2 fonctions me satisfait.
Je considère donc ce post comme validé.
This topic is locked and no more replies can be posted.