dbjoin details view and filter values

jh

Member
Hi

Sorry if Ive missed a simple solution but I have a db join used as an element in details view. This all works fine however I would like to use a different value for labels for details view and for the filter (different fields in the same table). Ive tried a few different settings but cant seem to get this to work. Hope this makes sense.

Kind Regards
 
Hmmm. You might be able to do it with the "eval options" on the join, although the trick would be making it efficient enough, as that code is called once per option. But the basic trick would be ...

Code:
if ($this->app->input->get('view', 'form') === 'list') {
   if ($opt->value === '123') {
      $opt->text = 'your replacement for option 123';
   }
}

I'm guessing you want to replace it with a different field(s) from the joined table, so of course you'd have to handle looking those up yourself. But you wouldn't want to do a lookup every time, as that would generate a lot of queries.

One option would be to use the new Custom helper, see ...

https://github.com/Fabrik/fabrik/blob/master/libraries/fabrik/fabrik/Helpers/CustomSample.php

... and set up a function in that Custom class, something like this ...

Code:
function changeFilterOptions(&$opt)
{
   // load and cache the table data once as static
   static $data = null;

   if (!isset($data)) {
      $db = \JFactory::getDbo();
      $query = $db->getQuery(true);
      $query->select('id, field1, field2')->from('yourtable');
      $db->setQuery($query);
      $data = $db->loadObjectList('id');
   }

   if (array_key_exists($opt->value, $data)) {
      $opt->text = $data[$opt->value]->field1;
   }
}

... then in your eval opts, just do ...

Code:
FabrikCustom::changeFilterOptions($opt);

-- hugh
 
Or maybe a 2nd dbjoin element, storing the same key via CCD or php plugin, hidden in form view

or - a bit overkill - a list copy used for details and list view with the alternate label

Gesendet von meinem SM-G930F mit Tapatalk
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top