Filter attributes from a List

02 Jun '14, 04:54 PM
2,488 Views
No Forum Badges

Hello,

I have a problem with my site view in my web project:

I'm creating a site where a user can add items to his user account. And once a user has added some items he/she should be able to have an overview of his/her items, this is where I'm stuck. I can get an overview with the List view component but I get every items from every user. So I would like to filter this list by only showing the items of the logged in user.

I have watched following tutorial: http://www.webratio.com/learn/learningobject/view-components-data-binding
But there they just compare an attribute to a value, I would like to compare it with the user's oid.

Can someone help me?

Best regards

 
x 0
Follow
Answer Answer at this question and get points!
Forum Starter - Level 1

Hi,

to filter the items by user, you first have to put a relationship between the user and the item entities, then, when you save the item, you should also connect it to the logged user (with a connect component or directly by passing the oid of the user to the relationship binding when saving the information of the item).

At this point you'll have the item with the information of the user who saved it, so you just have to add a relationship role condition to your list, select the relationship between the item and the user, and then pass the UserCtxParam (containing the oid of the user) to the condition with a get component.

I hope this helps!

 
x 3
No Forum Badges

Thank you Reberto for your answer.
I already tried doing what you said, but somehow I probably did something wrong because it still didn't work like that.

I finally solved it by making a new context parameter (with the username of the logged in user) and added an "attribute condition" to check whether the seller of the item corresponds with the username of the logged in user. 

(Before that I tried doing the same with oids, but it didn't work)

 
x 0
Answer at this question and get points!