Buy Now
Sign in

Where Conditions or Model Relation? Both?

cruser , May 12 2021, 17:15
C
cruser 103
May 12 2021, 17:15 #396443
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?
C
cruser 103
May 12 2021, 17:16 #396444
Here is the form
C
cruser 103
May 12 2021, 17:26 #396445
C
cruser 103
May 12 2021, 17:27 #396446
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).
C
cruser 103
May 12 2021, 17:28 #396447
GreyHead 65
May 13 2021, 09:36 #396453
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
If you'd like to buy me a coffee or two, thank you very much
C
cruser 103
May 13 2021, 12:07 #396456
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.
C
cruser 103
May 13 2021, 12:54 #396457
Edit: Didn't get, still trying.
C
cruser 103
May 13 2021, 15:01 #396459
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 65
May 14 2021, 10:11 #396471
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
If you'd like to buy me a coffee or two, thank you very much
C
cruser 103
May 17 2021, 13:31 #396489
That is EXACTLY what I needed, thanks Bob!