Posted by dale42 on February 21, 2007 at 2:27am
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!
| Attachment | Size |
|---|---|
| FieldToTableMappings.png | 20.35 KB |

Comments
sweetness
so cool. glad you are making this generic. my opinions:
Re the name
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:
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?
If we make the cells really small, this could resemble an X-Y scatter plot.
Group multiple values
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
'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
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
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
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!
@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
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
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.