Display user name by user id

veronique 04 Oct, 2014
Hello,

I make à chronoconnectivity list who requested table include user_id field. How display username in the same list ?

Thank you.
Max_admin 06 Oct, 2014
Hi Veronique,

You will need to add a new "Model", set the relation type to "belongs To", foreign key to "user_id", and the table to "users" table, set the Model name to "User".

Then you can use User.username

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
veronique 11 Oct, 2014
Hmm, nothing display in new column. Maybe the problem is that in one table user id is "user_id" field but in the other table is "id" field.
veronique 11 Oct, 2014
This the debug informations. In number 3 I don't see username field selected ?

Array
(
    [0] => SELECT `Extension`.`id` AS `Extension.id`, `Extension`.`name` AS `Extension.name` FROM `jnew_chronoengine_extensions` AS `Extension` WHERE `Extension`.`enabled` = '1' ORDER BY `Extension`.`ordering` ASC
    [1] => SELECT `Connection`.`id` AS `Connection.id`, `Connection`.`title` AS `Connection.title`, `Connection`.`params` AS `Connection.params`, `Connection`.`extras` AS `Connection.extras`, `Connection`.`published` AS `Connection.published` FROM `jnew_chronoengine_connections` AS `Connection` WHERE `Connection`.`title` = 'patronymes' AND `Connection`.`published` = '1'
    [2] => SELECT COUNT(*) AS `patronymes.count` FROM `jnew_chronoengine_chronoforms_datatable_patronyme` AS `patronymes` LEFT JOIN `jnew_users` AS `User` ON `patronymes`.`user_id` = `User`.`id`
    [3] => SELECT `patronymes`.`id` AS `patronymes.id`, `patronymes`.`patro_patronyme` AS `patronymes.patro_patronyme`, `patronymes`.`patro_variantes` AS `patronymes.patro_variantes`, `patronymes`.`patro_lieu` AS `patronymes.patro_lieu` FROM `jnew_chronoengine_chronoforms_datatable_patronyme` AS `patronymes` LEFT JOIN `jnew_users` AS `User` ON `patronymes`.`user_id` = `User`.`id` ORDER BY `patronymes`.`patro_patronyme` LIMIT 30
)
Max_admin 12 Oct, 2014
1 Likes
The query is correct, what do you have under the "Columns list" box now ? are you sure that your "user_id" fields are populated with valid users ids ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
guardian82 12 Oct, 2014
Where i have to put "User.username" in the Table for front list table to be show? Please a example
guardian82 12 Oct, 2014

Where i have to put "User.name" in the Table for front list table to be show? Please a example


I used this in the HTML textarea: Listar.cliente:{Cliente.name}
veronique 13 Oct, 2014

The query is correct, what do you have under the "Columns list" box now ? are you sure that your "user_id" fields are populated with valid users ids ?



Yes I'm sure. But how list could display "username" field value from "jnew_users" table when the SQL request don't select it like show debug :

[3] => SELECT `patronymes`.`id` AS `patronymes.id`, `patronymes`.`patro_patronyme` AS `patronymes.patro_patronyme`, `patronymes`.`patro_variantes` AS `patronymes.patro_variantes`, `patronymes`.`patro_lieu` AS `patronymes.patro_lieu`, `patronymes`.`user_id` AS `patronymes.user_id` FROM `jnew_chronoengine_chronoforms_datatable_patronyme` AS `patronymes` LEFT JOIN `jnew_users` AS `utilisateurs` ON `patronymes`.`user_id` = `utilisateurs`.`id` ORDER BY `patronymes`.`patro_patronyme` LIMIT 30
)


This is my "Columns list" box for front : [attachment=0]ScreenShot.jpg[/attachment]
The "utilisateurs" model details : [attachment=1]ScreenShot2.jpg[/attachment]
and second part of "utilisateurs" model details : [attachment=2]ScreenShot3.jpg[/attachment]
Max_admin 14 Oct, 2014
Please clear the "fields" box under the users model, the primary key is not retrieved and this is causing a problem!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
veronique 14 Oct, 2014
Well, I clear "fields" box under the users model, but username field is always not selected. How can retrieved it ?

Véronique.
guardian82 14 Oct, 2014
I had to create a new connection for it to work. Thanks for the support.
Max_admin 15 Oct, 2014
1 Likes
@Veronique,

Please clear the "Fields" box under all models, and try again, when this is done correctly you will be able to find both tables fields in the debug query!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
veronique 15 Oct, 2014
Answer
Yes ! Clear all "fields" box from all models, that is the solution.

Thanks
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger