Sort List By Current User

automan25

Member
I'm trying to get a list to only show records related to the current user by using a prefilter with the code below as explained in the wiki:

{$my->id}

The problem is it doesn't work. If I hard code the id of the current user to say "6", then it filters the list just fine. Any ideas what is going on here?
 
There's more to setting up a filter properly than just changing one option. What are the values in the other option columns?
The element that you are filtering/comparing as EQUALS to {$my->id} should contain the userid - and you must specify the raw value of that element if that element is configured to use anything other than the user ID as the label; else you would be comparing the label (i.e. the user name or username) to the id ({$my->id}) - and it wouldn't work; which is what I suspect you did.
 
I followed the directions on the wiki, which mentioned using the RAW value and setting the type to 'text'. As far as I know I have it set up correctly. Like I said, the filter works when I set the value to equal a specific user ID. It is the code to dynamically pull the current user id that seems to not be working properly.
 
Is the element you are comparing it to a 'User' element or just some 'Field' element that contains a userID - and if so, is it stored in the table as an integer or text? Try setting the type to 'No quotes' instead. I know the Wiki says to use 'Text' but that is what I use when comparing a 'User' element - or when comparing against a number (i.e. when comparing a field that is stored as a number/decimal). If you are using a 'User' element and still have a problem, try changing the placeholder to whatever you have the label set to be shown as - e.g. {$my->name} - in which case, you would use 'Text' as the Type.

You also didn't mention if the filter is being set in the List itself - or as part of a Menu configuration. (I have a feeling the 2 different possible 'set filter' situations might be behaving differently and that is what causes the confusion.)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top