• 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.

$my->id not working in prefilter

chris.paschen

Chris Paschen
I'm trying to use a simple pre-filter on a menu item to display a list of the user's items from a table.

In the menu item prefilter I have:

OR
Elements: UserID (name of field containing id of users' records)
Condition: Equals
Value: {$my->id}
Type: Eval
Access: Public

However, when I try to use this menu item from the front-end I get the following error:

0 syntax error, unexpected end of file

I have also tried changing the Value to:
'{$my->id}'

With same results.

Are these placeholders not available in the menu item prefilter area?
Or is there some other issue?


Running:
J! 3.6.5
Fabrik 3.5.2, Github as of 2017-02-06
PHP 7.x
 
"eval" expects real php code such as "return '{$my->id}';"
you should use "text"
 
Thanks. I tried changing that to text (and also used real PHP code version).
However then I didn't get an error; however, it was not returning any results.

After doing quite a bit more testing, I found that as long as I have the element's OPTIONS | USER DATA set to "Name" it won't find a match. I have to switch it to ID.
However, I need to have that set to "Name" for display purposes in other locations of my site.
In the past I had the option to select <fieldname>(raw) in the menu pre-filters; however that didn't appear for me.
After tracking it down, I found that on the specific element in LIST VIEW SETTINGS | FILTERS | FILTER DATA it must be set to 'Show all' to be able to select the 'raw' data in the pre-filter.
(Hope that helps someone with similar issues in the future)
 
After doing quite a bit more testing, I found that as long as I have the element's OPTIONS | USER DATA set to "Name" it won't find a match. I have to switch it to ID.

In the pre-filter, for the "Field", are you selecting "UserID" or "UserID (raw)"?

To match against {$my->id}, you have to select the "(raw)" option. The user element is just a special case of a join element, so has the concept of the "raw" value (the join key) or non-raw (the join label). In this case, the raw value (key) for the user element is the user id, and the non-raw (label) is whatever you are displaying (name, username, etc).

-- hugh
 
That was the strange thing. The "(raw)" option didn't appear in the pre-filter until I went to the LIST VIEW SETTINGS \ FILTERS | FILTER DATA for the element and set it to 'Show all'.

I though that "Show all" was the default. Either that changed somewhere in the updates for Fabrik OR somebody else went in and changed it for this element before I started working with it.
 
I found this worked !
pre-filters AND element 'X' condition> EQUALS
value return'{$my->name}'; Type > Eval

so logged in users only see in a list, forms assigned to them via element 'X'
 
It's best to use user IDs, not names, because names can change.

And you shouldn't have to use eval, type 'text' with just {$my->id} (or whatever) should work.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top