[Bad idea] How filter using Calculation element?

Status
Not open for further replies.

F.schettino

Italian
I have a table (List) in which I store user information
id ..... id_Joomla .....​

I need Joomla information on the List
Blocked , Group_ids

At the moment, I added a Calculation element to get Blocked/unblocked.
It works, also on the List: if I block/unblock an user, the Calculation element shows the right value ("Si" or "No"), but if I filter the list using "Si" or "No", the list shows no records.

Probably it depends on the fact that in the database I see NULL instead of "Si" or "No".

What I wrong?
or​
There is an other way to get what I need?

Can someone help me, please?


The code in Calculation element is:
PHP:
$id_utente = (int)'{fabrik_nominativi___id_Utente_Joomla}';
 
$db = JFactory::getDbo();
$query = $db->getQuery(true);
 
$query = "SELECT block AS Bloccato_Si_No FROM nuvrj_users WHERE id = " . $id_utente;
$db->setQuery($query);
$bloccato = $db->loadResult();
 
if($bloccato == 0)
  {$bloccato_si_no = "No";}
else
  {$bloccato_si_no = "Si";}
 
Filters operate on the values that are stored in the database. So you can't filter on a calc element if it is just calculating these values when the list is rendered.
 
Hi, rackem.Thanks for your interest.

I tried also to put a query to update the value, before
return $bloccato_si_no;
but it doesn't work.

To avoid any problem, I think the best way is develop my PHP code...
 
Hmm, if I understand what you want to do, I don't think the calc element is a good choice. You need a way to get the user info data into your list to be able to filter on it.

I wonder if you could add a Left Join from your List to your user info table. That would bring those elements into your list. Or perhaps just adding a read-only dbjoin element to bring in the data - the default value would be the user id and the "label" would be "block". Although I think either of these methods would just bring the block value over so you would still need a way to display "Si" or "No" as appropriate. There might be a way to do this with the Eval options in the dbjoin element.

Sorry I don't have more specific instructions, just potential ideas. I don't think I've tried to do this type of thing before but I'm pretty sure there is a way to do it with Fabrik.
 
I'm sorry; I didn't answer you before because I wasn't at home last days.

I tried to add a Left Join to the user info table, but in the form I use Groups and Fabrik generates a new Group for linked tables; I don't like a Group containing only 1 field...

I will try again to use Juser plugin (I have problems using it; see my discussion Problems using juser form plugin), then I will be obliged to work around, writing my code.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top