views:

53

answers:

2

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.

A: 

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.
googletorp
+1  A: 

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.

jhedstrom
Man, i could have used this module in my past 3 projects.
easement

related questions