• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[solved] Fabrik List Module: Display row matching id of current detail view

aijosh

Member
Hello,

I have a module (List Z) which I want to display but with only the record (on List Z) matching the id of the current detail view of (List Y) to be displayed.

How do I achieve this?
 
So is the module only being display on the Fabrik detail component page for List Y?

In other words, is the rowid of the record being displayed for Y in the URL query string?

If so, you should be able to use a placeholder for that query string field in a prefilter for the module, like {rowid}

-- hugh
 
So is the module only being display on the Fabrik detail component page for List Y?
I would prefer this but I'm not sure I know how to achieve this. The module shows still shows in the list view of the menu. I'll prefer if it loads only when the user clicks into the detail view.

n other words, is the rowid of the record being displayed for Y in the URL query string?
I see numbers in the URL (url/xx/xx) I believe that is (url/formid/rowid).
BUT
I plan on setting up and using fabrik sh404sef to get rid of this and show username (if possible) instead so I dont know if finding the rowid in the url is an option

If so, you should be able to use a placeholder for that query string field in a prefilter for the module, like {rowid}
I think I've seen how to do this somewhere on this site. Have to dig for it again. I dont mind if you share a code snippet here.

Thanks
 
Well, it doesn't matter how the URL represents the view and rowid, whether it's un-SEF'ed, &view=form&formid=123rowid=234, or standard SEF, /details/123/234, or 404sef'ed to something custom /foo/your-name-here ... once it's been through the router, the input variables for view, formid and rowid will be set (that's pretty much what SEF routing does ... picks apart a more human / SEF friendly URL into the query string parts the component expects).

So by the time pre-filters or element defaults are being built, code like $app->input->get('rowid'), or {rowid} as a placeholder, will work.

Not knowing how your lists Y and Z are related, I can't really give you the exact details, but I'd expect one of two setups - either you have list_z.list_y_id (so a foreign key on Z pointing to the id of Y) or vice versa, list_y.list_z_id (foreign key on Y pointing to the id of Z).

If it's the former, then the pre-filter is straight forward, just ...

Field: list_y_id
Condition: EQUALS
Value: {rowid}
Type: text

If it's the latter, such that you have to grab the FK from list Y, you'd have to use a subquery to get the FK from list Y ...

Field: id
Condition: EQUALS
Value: SELECT list_z_id FROM list_y WHERE id = '{rowid}'
Type: query

-- hugh
 
Great! Thanks. Never understood how to properly use the query option. I believe I do now.

Is it possible to prevent the module from rendering if no record is found?
 
Field: id
Condition: EQUALS
Value: SELECT list_z_id FROM list_y WHERE id = '{rowid}'
Type: query

Ok. This worked but I did run into an issue.
All the records returned in this list link to only the record in the initial detail view and I can understand why.

I'm now trying to instead read another columns value for the same row (on List Z) then use that value to load the ones I need (on List Y)

I tried using eval

$rowid = $app->input->get('rowid');
$db = JFactory::getDbo();
$db->setQuery("SELECT user FROM tableZ WHERE (id = $rowid)");
$ownerid = $db->loadResult();
return($ownerid);

but the best I'm getting is a null error
 
Last edited:
I believe you are correct but my current setup is kind of complex.

Summary:
I need to read the userid column of the current detail view.
Because the module exists on multiple lists. Hence the rowid doesn't always work as I navigate from list to list

Details (if it would help):

ListZ
--------
id
userid

ListY
----------
listz.id
userid

ListX
---------
id
userid


What all lists have in common is the userid which is not a key element as I believed it would be safer if fabrik generates the ids for the rows instead of trying to force the userid into the primary key of the table (or I wasn't sure of how to implement it correctly so I decided to play safe by making it a regular element).


I need the userid to call the records but making use of the rowid doesn't work in a lot of cases.

I'm assuming the eval would allow me select the userid from the tables.
 
Last edited:
Update:

I'm currently achieving the behavior I want using OR on the pre-filter.
So, I'm adding a line for each List that this module would display on.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top