Drupal Views search by one field and sort by another - drupal

I have a problem with Drupal Views.
I have a content type "Company". "Company" has a "City" field (taxonomy term reference) and "Company type" field (A,B,C).
How can I – inside a view – search for City and order by Company Type at the same time?
For example I want to search for Paris. And then I want all Paris Companies sorted initially by Company Type. First A, then B, then C.
How to enable sorting like that?

It depends a little bit on how you display your companies. As table or as list? But generally you simply can add multiple sort criterions.

Related

Make Drupal 7 Group by always show grouping field

I have a Drupal 7 view similar to the one described here: Drupal 7 Views - list group by field
I wish to have all the groupby fields always appear even if there are not members of them and ideally I wish to put a default value in such a list.
eg:
Foo:
-Jay
-George
Bar:
-Barry
Boo:
Sorry no entries at this time!
Suggestions?
If none of what you are fetching with the view is associated with the group 'Boo' then the view doesnt know it exists, so would never be able to show it but say there is no results for it.
What i would recommend is creating a taxonomy vocabulary with the terms: Foo, Bar, Boo.
In whatever content type your names belong to, create a term reference field, and link them to the terms.
In the view, fetch the taxonomy terms, create a relationship to the content type that references the taxonomy, and pull those through based on that. There is a setting in views for multiple results to combine into one field (so you would want to do that). Then you could add the 'Sorry no entries at this time!' as a field's no results text.
So to recap: VIEW => TAXONOMY TERMS => NAME CONTENT

how to limit view to just show each type one time?

I have a content type what is news, the news has a field type that is List (text) to keep different types of news. for example I have Health, Sport, Economic and etc.
So now I am going to create a block and have each of these type in that as a hyperlink.
I can do it and I created a new view block but each news_type may showing more than one time according to published content.
How to set the view (for block) to just show news_types and show them just one time?
You can achieve this by following the steps given below:
Enable aggregation under Advanced Accordion of the view
Add Nid field & set aggregation type as Count Distinct
Exclude Nid field from display
Add news type field & set Aggregation type as Group results together, in Group Column select Value option from dropdown
Remove Publishing Date from sort criteria
Please check attached screenshot for reference
You can check this question for more information, and maybe help you.

How to filter a field in the add content window in Drupal?

I am very new to Drupal so I'm sorry for my lack of familiarity with Drupal terminology.
I have a content type with multiple fields (A, B, C, etc..). Each field is a selectable vocabulary list. I would like the user to select any terms in A and B fields. But I want only relevant terms to display in the C field (depending on A and B selections). In this way, A and B are independent fields and terms that appear in C are dependent.
Example:
Content type: Food dish at a restaurant
Field A: Appears on Menu type (Breakfast menu, lunch menu, dinner menu, wine list,etc.)
Field C: Appear in Menu section (Appetizers, Entrees, Deserts, etc.)
If the user selects "Breakfast Menu" for field A, it wouldn't make much sense to allow the user to select "Desert" for field C. But selecting "Appetizers" or "Entrees" would be fine. I want to filter the selectable terms in field C depending on which options are selected for field A.
Thank you for helping me out! Really :)
A quick solution is to use Simple hierarchical select or Hierarchical Select. But in this case, you will have to combine all your terms inside one taxonomy vocabulary taking advantage of taxonomy's parent-child relationship. And Hierarchical Select will take care of the rest.
Hierarchical Select Documentation.

How to add additional field to drupal organic group 'User and Group' relation?

Im using Drupal Organic group module and I want to create a group and need to assign users (filter by perticular role) to that group. I have done that part easily but the problem is that, I need to add aditional note on per each group user relation.
Lets say there is a group called "School Prefects" and need to add users to that group whos role is student. In here I need to put a small description for each relation.
Please help me to figure this out.
Thanks in advance.
I will probably deal with the same problem soon.
I think a possible workaround is to use the relation module and
the rules module. You could set up a rule to create a relation
each time a user is assigned to a group, or something like that.
Relations made by the relation module are fieldable. But it would be
maybe better to add a field to the og user-group relation directly.
Update: now that I tackled the issue, I have a different solution. We don't need to add new relations, the og_membership shipped standard with og is all that we need. This is how I did it.
I created a new membership type from admin/config/group/group-membership. It's a fildable entity so I added the required fields: in your case it will be "description".
Then I changed the used membership type per user, I did it in admin/config/people/accounts/fields/og_user_node (I needed to change the field "group membership" in user account).
So, now when you (or a group administrator) go to "manage group page" (clicking the group tab in group node), where you can add new people or manage members, either way you can edit your custom field "description" on each membership users-group.
Besides, you can clone the "og members" view adding the field "description", so in people panel in the group homepage we see name + description.
I my use-case I had to see (per group member): name, role, start date, end date. E.g. John Doe, president, from 1997 to 2003.

Drupal 7: Search fields

I've just started to learn Drupal and decided to implement a simple "Student list" site.
In my content type "Student" I have added a numerical field "age". And now, after entering some content and reindexing I want to perform search on the "age" field.
If I enter some valid age into search box, then nothing is found.
How do I find students by age or by age range?
If you're new to Drupal, each of these steps will require its own instruction. Luckily, there are plenty of tutorials on the interweb.
To create a sortable/filterable list page from your student content type:
Create a view from the student content type.
Set the new view's display type to Table View and ensure that the the age colum is listed as a field you want to display.
Set the table's headers to clickable (so that you can sort your list when it's displayed.)
Use exposed filters to allow people to filter your group by an age, age range, or other criteria (e.g. last name, etc.).
I'd consider the following searches for each step:
Drupal 7 Create View site:youtube.com
Drupal 7 Table View Display Format
Clickable Table View Headers in Drupal 7
Drupal 7 Exposed Filter site:youtube.com

Resources