I need to build a view so that a user can see technical papers of all the people who work for the same company.
This means implementing views to filter on the dynamic value of a profile attribute. There are filters on Current user, user status etc. I wanted to filter on the
user attribute of company.
What I have with me -
I have implemented the following -
1. Enabled profile module
2. Added 2 fields to the user profile -
* profile_job_title - which is an autocomplete textfield
* profile_company - a select list pre populated by site admin which contains the names of the company eg - Microsoft, Google, Yahoo, etc
3. Users are created by the site admin and he assigns them the property of the company to which they belong.
4. Created a new content type 'file' which is a filefiled cck field on a node
5. When these users log in to the site they can upload their files/ technical papers.
Requirement -
I wanted a view which said Uploaded papers of your company. This page would allow the logged in user to see all papers that are submitted by users
belonging to the same company
How I achieved this -
1. I decided to pass the company name dynamically as a parameter to the view.
2. I created a new view of the type node from Views > Add -
3. I selected formatting options like table type, fields to be displayed, etc
4. I defined a path dev/%/upload where % would be the logged in user's company name which I will be passed as an argument to the view

5. Passed the argument as dev/%/upload Hence declare that profile company would be passed as an argument
6. I defined the filter for 'Profle Company field' and selected the Override option
7. Also selected other filter on 'node type' to be file
8. Click the Override option so that the value of this filter is picked from the argument and overrides any default.
9. While doing this, you can continue watching the Live preview on the same page towards the bottom of the configuration form
10. Finally select 'Page' as Display and enter an argument for the Company field. In my eg, I have added EA Sports as an argument. Click Preview. What you see is all files uploaded by users whose Company name is EA Sports. The company field shows the company name as well.
Hope this helps ! In the next post I will show how to ensure security and add validations to the view.
0 comments:
Post a Comment