Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 740 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drupal: Views: grouping relationship in block list

#1
I have a question about views, specifically about grouping a relationship. I have a "partner" node that has many "docs", I want to list the name of the "partner" along with its corresponding "docs" below. I have the relationship set up correctly(I think) but can't figure out how or where to group it correctly.

I get this:

partner name 1
- doc name 1
partner name 1
- doc name 2
partner name 1
- doc name 3
partner name 2
- doc name 4
partner name 2
- doc name 5
partner name 3
- doc name 6

but would like this:

partner name 1
- doc name 1
- doc name 2
- doc name 3

partner name 2
- doc name 4
- doc name 5
- doc name 6
Reply

#2
It sounds like you're on the right track. In order to get the grouping to work as you outline above, you'll need to set the display style to 'html list', and then under the style options, set the grouping field to the partner name. Once you have this working, you can edit the partner name field, and select 'exclude from display', which should then give you the desired format.
Reply

#3
I ran into this same problem today. In an attempt to troubleshoot, I made a new empty installation of Drupal and added only my content type and the relationship. When I created the view I did not see the problem. Once I started adding modules back in I found that the theme developer in the development module is causing the problem. Try unchecking it and reloading your view. You might also be able to see this by leaving the item checked, opening up a different browser and going to the view as someone that will not see the theme developer.
Reply

#4
I have had some success using the [views_field_view][1] module which allows you to specify a view as a field.

First I created a view with the single field that I wanted to group by and then over-rode the query using the following code.

function hook_views_pre_execute(&$view) {
if ($view->name == 'phone_search') {
$query = 'SELECT DISTINCT node_data_field_status.field_status_value AS node_data_field_status_field_status_value
FROM content_type_phone node_data_field_status';
$view->query->query = $query;
$view->query->final_query = $query;
$view->query->count_query = $query;
}
}
The reason for this is that views automatically includes the `nid` and the `vid` fields when you have it set to select distinct so you don't actually get the distinct values. By hacking the query like this I worked around this issue.

The `views_field_view` module allowed me to create a second view with the fields that I wanted to be shown in the groups. When you add the view_field to the primary view (the one that the query is over-ridden in) you can specify a field to pass in as an argument. This argument must then be specified in the child view.

It all is a bit complicated but I hope this was clear!


[1]:

[To see links please register here]

Reply

#5
This is something views is weak at.

I usually write a module to produce these kinds of results as I find writing sql to quicker and more maintainable than wrestling with views to do it.

That said, there are many views plugins out there that offer this type of functionality. I have not tested them because I find this easier handled with a small amount of custom code in general, but here are a few projects seeking to provide a solution to this type of thing for views.

[To see links please register here]


[To see links please register here]


There are many others, but I can only post two links because I don't often answer questions on this site :)

cheers

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through