Filter Current user in Fabrik Content Plugin

Status
Not open for further replies.

tiopourtu

New Member
Hello,

I used Fabrik Plugin in my article showing a List named Briefcase (ID=3). The table has field named wnd_bcase___createdby and wnd_bcase___access.

When I put this code:
{fabrik view=list id=3 wnd_bcase___access=1}

the user has all data in list 3, with access=1.

I want to filter based on criteria that wnd_bcase___createdby is equal current joomla user ID such as:
{fabrik view=list id=3 wnd_bcase___createdby=xxx}

Anybody has any idea what to write for the xxx, cause $my->id doesn't work.

Thanks in advance.
 
try:

{fabrik view=list id=3 wnd_bcase___createdby=[$my->id]}

or

{fabrik view=list id=3 wnd_bcase___createdby_raw=[$my->id]}
 
Many thanks Rob,

I try to use [$my->username] and it works. But new question came up, while using these codes:

{fabrik view=list id=3 wnd_bcase___createdby=[$my->username] wnd_bcase___access=1}

{fabrik view=list id=3 wnd_bcase___createdby=[$my->username] wnd_bcase___access=2}

{fabrik view=list id=3 resetfilters=1 wnd_bcase___access=3}

The first line showing records created by current user with access=1 (Private access). The second line showing records created by current user with access=2 (Shared access).

But the third line was supposed to show records with access=3 (Public) created by any user. In fact, it show records with access=3 (Public) created by current user. It means I can't use the resetfilters parameter here. Anything wrong with the codes ?

Thanks again.
 
try:

{fabrik view=list id=3 clearfilters=1 wnd_bcase___access=3}

Not sure that will work, if it doesn't report back and I'll set up a test case to see what is going on
 
Thanks Rob, but unfortunately it didn't work.

But if I change the codes in the following order,it works but that's not answering the question.

{fabrik view=list id=3 wnd_bcase___access=3}

{fabrik view=list id=3 wnd_bcase___createdby=[$my->username] wnd_bcase___access=1}

{fabrik view=list id=3 wnd_bcase___createdby=[$my->username] wnd_bcase___access=2}

Line #1: showing all record with access=3 (Public) created by all users
Line #2: showing all record with access=1 (Private) created by current user
Line #3: showing all record with access=2 (Shared) created by current user

Still figuring out why it happens.
 
ok I've fixed this in the code @github. My test plugin code, which is working was:

Code:
{fabrik view=list id=1 element_test___dropdown_raw=1 element_test___user_raw=[$my->id] resetfilters=1}
 {fabrik view=list id=1 element_test___dropdown_raw=2 element_test___user_raw=[$my->id] resetfilters=1}
 {fabrik view=list id=1 element_test___dropdown_raw=3 resetfilters=1}

the issue was the the previous user filter was still there in the last {fabrik...} but with a value of '' which produces 0 results.
 
Ok then,

I'll update the code from github and try again just the way you code it.
If it still doesn't work, I'll report back to you and keep this thread open.
If it works, I'll report back and close the case.

Thanks
 
Dear Rob,

Here is my test code and its result.
Code:
{fabrik view=list id=3 wnd_bcase___access_raw=1 wnd_bcase___createdby_raw=[$my->username] resetfilters=1}
{fabrik view=list id=3 wnd_bcase___access_raw=2 wnd_bcase___createdby_raw=[$my->username] resetfilters=1}
{fabrik view=list id=3 wnd_bcase___access_raw=3 resetfilters=1}

Result:
First line, showing no records
Second line, showing no records
Third line, showing public document (access=3) created by all user, as expected

Code:
{fabrik view=list id=3 wnd_bcase___access=1 wnd_bcase___createdby=[$my->username] resetfilters=1}
{fabrik view=list id=3 wnd_bcase___access=2 wnd_bcase___createdby=[$my->username] resetfilters=1}
{fabrik view=list id=3 wnd_bcase___access=3 resetfilters=1}

Result:
First line, showing private document (access=1) created by current user, as expected
Second line, showing shared document (access=2) created by currenet user, as expected
Third line, showing public document (access=3) created by all user, as expected

I don't know what the different between using _raw or without _raw, but so far I used your code without using raw and it works as expected. So I can close this topic now.

Many thanks.
 
_raw contains the userID (so you must filter with $my->id, which is unique in all cases), the element without _raw contains whatever you've set to display in your userelement (in your case username, but could be email..., so you must filter with $my->username or $my->email)

You can close the thread with the "Thread tools" at the top of the thread.
 
Dear troester,

That explained why the first code generating results with no records. Thanks for the explanation.

Problem solved! :)
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top