English 中文(简体)
grouping items in a view
原标题:

I have a content type called "convention" and a content type called "convention session". Each session has a node reference to a convention. A convention has a "from date" and a "to date", and each convention session has a simple "from date".

When a user browses to the full node view of a convention, I want a block to be displayed on the left that displays a grouped list of convention sessions that occur between the "from date" and the "to date" of the convention. So, for example, if you take a look at the convention node called "My Awesome Convention" from 12/10/09 to 12/12/09, I want the block to look like:

  • Thursday (5) - (the numbers are the number of convention sessions on each day)
  • Friday (12)
  • Saturday (15)

Then, I want each of those items in the block to link to a page view that lists all the convention sessions from that day, with the block staying on the left. Can t figure it out. Any help would be greatly appreciated.

最佳回答

When you want to work with the context of your site - the node being viewed things get a bit complicated. I m not sure, but you might be able to get the node id you want to use from the url. Else you have a few other options.

  • Panels created by the views author is a module, that is designed to change layout and also is able to pass contexts around. In this case, however, it will probably be too much work for you to get to know it.
  • Making the block yourself, is always a possibility. With views not many do it, but my guess is, that it will be a lot easier to create your own module and implement hook_block(). Here you could make your logic and SQL yourself. IF you don t know Drupal API and PHP very well, this will be a bit hard. But else this is something that can be done in a few mins.
问题回答

The views module doesn t allow for aggregate SQL functions by itself. However, there is Views Group By module, which should allow you to aggregate these counts.

As for determining the convention sessions belonging to the convention being viewed, you should be able to do this by using views arguments. Since the node reference field points from sessions to convention, you would add that field as the argument, and pass a default value in using the Node ID from URL option.





相关问题
Drupal Multi-language: Simple strings not translated

I m adding additional languages to a Drupal site that I m building. Getting the translation of content working is fairly easy using the Internationalisation module. Yet, simple things such as date ...

Setting up a WYSIWYG editor for Drupal site users [closed]

Looking through the Drupal contrib modules, and after a few Google searches, it becomes evident that there are any number of choices and combos available to set up a WYSIWYG editor in Drupal. I m ...

Change size of user/password login box

I don t know how to change the size of the login username/password boxes on the drupal site that I m trying to build. I m stumbling through the theming, and don t know where to find the file that ...

How does Drupal provide an edit/review/publish model?

How does Drupal support a means to update and review a website before it is published? Does it only allow you to preview a page at a time before you publish it or is there a way to create a site ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

Has anyone checked out Drupal 7? [closed]

Has anyone checked out a copy of Drupal 7 yet? What do people think? I m pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure. Do ...

热门标签