Pre-filter eval not working.

Joomla 3.3
Fabrik 3.1
Last Github update: 8/15

This is a bidding site with a limit on how long a project is up for bid.

date time (standard Fabrik element) = date project submitted
fb_projects___tender_timeframe = # of days bidding is open (it's a radio button with # of days as value)

My eval code:

$int = (int) '{fb_projects__tender_timeframe_raw}';
$limit='- '.$int.' days';
$today=date("Y-m-d");
$terminus=date ('Y-m-d',strtotime($today.$limit));
return $terminus;

If I substitute a value for $int, like $int='10';, the filter works. The problem is clearly with the first line, which is taken from this WIKI page on Eval coding.

Is the eval box for pre-filters working with placeholders? Is the syntax in the WIKI wrong (though I've tried double quotes, without quotes, without brackets, etc., etc., etc.).
 
At least you need 3 underscores in
$int = (int) '{fb_projects___tender_timeframe_raw}';
 
You can't use element placeholders in the prefilter (you can use e.g. {$my->id}).
The prefilter is creating one condition to select DB table rows.
 
Here's what the WIKI says about the Eval type of condition:

  • Eval - fabrik expects the value to be a piece of PHP code that returns the value to search on. So, we can make the same prefilter as in the first example if the type is set to eval and our value is: return 'John';
So it's not possible to use, e.g. return '{my_table___my_element}'; ?
The Eval option is of very limited utility then. That combined with the fact that the prefilter doesn't work with calc elements is a pretty serious limitation.
 
A prefilter is creating a MySql query.
Your eval is evaluated once per list, not per record and must return a string usable in this MySQL query.
e.g. 'John' if you want to do "WHERE name EQUALS evalreturn"
or (5,7,9) if you want to do "WHERE id IN evalreturn"
What do you expect if you use an element placeholder?
element = a in record1
element = b in record2
It doesn't make sense.
 
It would be quite simple if I could use a pre-filter on a calc element. I have an element that calculates days remaining to bid for each record. If that element is less than 0, I don't want the record displayed in the list. But pre-filters don't work on calc elements. So I need to pull the element that contains the number of days a project is open to bidding to calculate whether the time has expired or not. (Users can pick from a couple of options for how long bidding should be open: 14 days, 28 days, 42 days.)
 
After your explanation, and now knowing that I can't filter by record, I changed my setup so that I calculate the end date for the bidding process and store that. Then I use the eval option to get the date and filter for dates equal to or greater than today's date.

Thanks for your explanation.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top