hominid4
Member
Code:
Table: class
id|class_name|class_code
==========
1|Class One|CC-1-9861
2|Class Two|CC-2-3254
Table: student
id|student_name|class_id
==========
1|Bill|1
2|Susie|1
3|Larry|2
"url_to_list?code=CC-1-9861" will only show Bill and Susie.
Everything works as needed, except when clicking on a record within the filtered list I get a "unable to find this record" error, because I don't have a custom link that includes the "code" URL parameter - which I can't figure how to do.
In the `student` List's 'Data > Pre-filter' I have:
Field: class_id
Condition: EQUALS
Value: code below
Type: Eval
Apply to: Public
PHP:
$classCode = $this->app->input->getString('code', '');
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$tblClassEsc = $myDb->quoteName('class');
$classCodeEsc = $myDb->quote($classCode);
$myQuery = 'SELECT id FROM '.$tblClassEsc.' WHERE class_code = '.$classCodeEsc.' LIMIT 1';
$myDb->setQuery($myQuery);
$classId = $myDb->loadResult();
return $classId;
url_to_list/form/14/{rowid}?code={code}
I know I can add a corresponding `class_code` column to the `student` table and just use that placeholder within the Custom link, but I'm attempting first not having to depend on that.
Any suggestion on how I can "re-grab" the "code" URL parameter for the Custom Link?
Thanks!
Joomla: latest version
Fabrik: latest GitHub
Last edited: