Where Conditions or Model Relation? Both?

cruser 12 May, 2021
Hopefully, I'll be able to explain what I'm trying to do and someone here can help me figure out whether I need to use a Where Condition or Model Relation. I have a table list that lists Joomla users from the #_users table. The name of the user in the list is linked to "listing.viewArticle" where the URL parameter name is "id" and the parameter value is {var:User.id}. Clicking the link takes me to the listing.viewArticle details page. On that page, I have name, dates, and other field information displayed. All is good!

Here is where I need help with using Where Condition or Model Relation. On my listing.viewArticle page I have another table list that displays information from a MySQL table that I created #_user_policy. It is intended to show records only for that Joomla #_user. The issue is that all records from #_user_policy are being shown. What I need is records from #_user_policy for Joomla #_user (id 623 for example) to load. The #_user_policy table has the Joomla #_user id in it.

I keep working myself into circles and can't seem to get over this hurdle. Any help?
cruser 12 May, 2021
Here is the form [file=https://cgorr1.com/MBA.cf7bak]File backup[/file]
cruser 12 May, 2021
in my #_user_policy table there are three entries, two for John Doe (user id 623) and one for Chucky Beast (user id 647). I only want to show records for John Doe (623).
cruser 12 May, 2021
[file=https://cgorr1.com/MBA.cf7bak]Form Backup[/file]
GreyHead 13 May, 2021
Hi cruser,

I think you need a Where Condition set to match the current user id to the column in your #_user_policy table

Bob
cruser 13 May, 2021
Bob- any idea what that would look like? I cannot for the life of me figure out what magic combination I need to use to match the current user id in the #_user_policy table column.
cruser 13 May, 2021
Edit: Didn't get, still trying.
cruser 13 May, 2021
Rather than showing the records of the current logged in user, I only need to show the records of the user selected from the table view. John Doe is in the joomla #_users table with id 623. John Doe's name is linked to "listing.viewArticle" where the URL parameter name is "id" and the parameter value is {var:User.id}. Clicking the link takes me to "gpage=viewArticle&id=623" page. So far so good!

The table list I have on "gpage=viewArticle&id=623" displays information from a MySQL table that I created #_user_policy. In the #_user_policy table I have a column named "employee" that has the user's id in it, in this example "623".

I log in as user id "650".

When I add the where condition "employee = {user:id}", click "gpage=viewArticle&id=623" I get records that belong to my user id "650" and not user "623".

I need to display records only for Joomla #_user John Doe with id 623 no matter who is logged in.
GreyHead 14 May, 2021
Hi cruser,

The sortcode {user:___} gives you info for the current logged in user i.e. id=650. Please try instead {data:id} which should give you the value from the calling URL. More info in the Shortcodes Cheatsheet from the book icon near the right hand end of the toolbar.

Bob
cruser 17 May, 2021
That is EXACTLY what I needed, thanks Bob!
You need to login to be able to post a reply.