Two Axis Grid Views Plugin

Events happening in the community are now at Drupal community events on www.drupal.org.
dale42's picture

I'd like some advice from the group on how to proceed with a Views plug-in module I'm working on.

I've taken my work from the scheduling grid and, using the Bonus Pack as an example, created a working views plug-in that adds a new View Type. Working name is "Two Axis Grid".

The row and column fields are designated by their position in the fields group on the Views UI. The first field is row, the second is column. Any fields after that are placed in the cell. Hopefully this diagram will give you an idea of how this works:

My Questions:

  • I'd like to submit this to contrib, should I do so as a new module or a patch, perhaps to Bonus Pack?
    (I'm asking this in part to justify a CVS account if it should be a new module)
  • Two Axis Grid an ok name? Other suggestions?
  • Is it too much of a kludge using field position to determine the field's role (column/roll/cell data)?
    There isn't a method I know of to extend the Views UI so I can query for this additional information. Positional seemed like the next best thing. Other ideas?
  • Related to the point above. The title field has additional text: Display the title of the node. Is it possible to add a text string like this based on selected view? Then I could add "This field is the designated row", making it a little more obvious.

Any and all comments appreciated. Thanks!

AttachmentSize
FieldToTableMappings.png20.35 KB

Comments

sweetness

moshe weitzman's picture

so cool. glad you are making this generic. my opinions:

  1. Views Bonus Pack, unless you really need own module for other reasons
  2. Aren't all grids on 2 axes? I'm not fond of the name, but can't think of a better one. so go ahead :)
  3. Field position seems reasonable here.
  4. Yes. You can use hook_form_alter() to adjust just about anything on this page. Nice idea to adjust descriptions.

Re the name

dale42's picture

Thanks

> Aren't all grids on 2 axes? I'm not fond of the name, but can't think of a better one. so go ahead :)

The Bonus Pack has a grid named: Bonus: Grid View. It produces a kind of sequential grid like:

+----+----+----+----+
| n1 | n2 | n3 | n4 |
+----+----+----+----+
| n5 | n6 | n7 | n8 |
+----+----+----+----+
| n9 | n10| n11| n12|
+----+----+----+----+

where all of the selected fields are contained in each cell.

I'm also not really fond of the two axis grid name, but wanted to avoid confusion between the two. And I couldn't think of anything better, either :-)

Scatter plot?

njivy's picture

If we make the cells really small, this could resemble an X-Y scatter plot.

Group multiple values

moshe weitzman's picture

Also, 'Group multiple values' handler comes from your code? That seems quite useful even outside of the grid. Maybe Views provides this but I missed it.

'Group / Ungroup multiple

yched's picture

'Group / Ungroup multiple values' option is provided by CCK for all CCK fields, moshe ;-)

@torelad : this looks really neat indeed. thnaks for contributing this.

Crosstab or Cross Table

karens's picture

How about crosstab or cross table as a name? That's what is used in spreadsheet programs for grids like this.

No way that I know of to add text to those fields, but I think it's OK to just make that clear in the instructions. I've also started using hook_form_alter() on the Views edit form ($form_id = 'views_edit_view') to insert validation or error messages about things like 'You must have exactly two fields in the fields section' or whatever your message would be.

This is great! I'm glad to see someone working on this, it would be very useful.

Plugins can actually have a

merlinofchaos's picture

Plugins can actually have a 'validate' function, I think. I'd have to doublecheck but I'm fairly sure that they can, anyway.

I'm not sure I understand what this actually does without looking at it. I've yet to get a chance to come back to it, but I will try to.

The bonus pack is available for things like this to be added, though one problem I've been having with the bonus pack is that contributors aren't doing a good job of maintaining their add-ons =)

Ohh! The actual post

merlinofchaos's picture

Ohh! The actual post contains a PNG! Spiff! I was just reading the text email and hadn't seen that.

Ok, now I see what this does. And yea, that's pretty damn cool. I'd love to have this in the bonus pack.

It's a deal!

dale42's picture

@KarenS: I like Cross Table better than two axis grid. Even better that it's a standard name. Done!

@merlinofchaos: Excellent, Bonus Pack it is.

Thanks for the feedback, everyone.

There is a validation option

karens's picture

There is a validation option in the plugins array. I've even used it, but I forgot about it. Add 'validate' => 'my_validation_function' to the array in views_style_plugins hook. Then you can copy the default validation (which is in the views_ui.module) to your custom function and alter as needed to validate for the things that ought to be in the view.

I must admit I'm one of the developers that has neglected things in the bonus pack. I forgot to subscribe to the issue queue and never think to go back and look at it. Maybe I'll do better going forward :-)

Status

dale42's picture

I've submitted a (hopefully correct) patch to add cross tables to Bonus Pack for Drupal 5: http://drupal.org/node/121730

I have a working back port for 4.7 that I'm finishing up.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week