Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-beta4
Component:
Views Data
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2008 at 11:30 UTC
Updated:
12 May 2013 at 14:50 UTC
Add a select to alter table headings down the left as apposed to at the top of a table (specifically useful if fields have very long titles)
e.g.:
<table>
<tr>
<th>Very very long field name with extra information</th>
<td>Node id x field value</td>
<td>Node id y field value</td>
...etc.
</tr>
<tr>
<th>Another very very long field name and even more information</th>
<td>Node id x field value</td>
<td>Node id y field value</td>
...etc.
</tr>
</table>
Comments
Comment #1
merlinofchaos commentedDue to the complexity involved with tables, plus column sorting, this would probably need to be a separate style plugin. It's neat, but it strikes me as being used only very very rarely, and I don't think I'm going to put it in Views core. Sorry.
(As a workaround you might try the grid view, which does have a horizontal/vertical switch)
Comment #2
uberellis-dupe commentedAw :( Forgive my ignorance - part of me hoped it was a simple row to column switch (Didn't consider sorting, truth be told o: ). I'll give grid view a shot! Thanks for the rapid response! :)
Comment #3
MadOverlord commentedJust posting this as a possible fix; I needed this kind of layout to nicely format a bunch of product information (20 or so fields), and the current layout options just didn't cut it. For this kind of stuff, a vertical table is just the ticket, since you can get the rows to line up in a nice way.
I couldn't find a style plugin that does this (if there is, let me know) so I hacked together a couple of theme files that change the unformatted output to a formatted table. There are several limitations on this (no grouping, no table headers) but it does what I need and may be helpful to the NPB (Next Poor Bastard).
You need to make your own versions of the style output file (originally views-view-unformatted.tpl.php) and the row style output file (originally views-view-fields.tpl.php) and tell your view to use the new versions. Here's the code for the style output:
and for the row style output:
Comment #4
smaier commentedThis may help.
http://drupal.org/project/views_two_column_table
Comment #5
MadOverlord commentedYes, that looks like it does the same thing. Wish I'd found it before I did the above hackery but both would seem to do the trick.
Thanks for taking the time to add the linkage; it will help TNPB (The Next Poor Bastard)
Comment #6
kiliweb commentedYou can also override the output theme of the table style (something like : views-view-table.tpl.php)
Here the code :
Comment #7
mattbk commentedWill this template work with D7? For the life of me I can't get the display to change for the view I am working on.
Comment #8
mattbk commentedNever mind, I was assuming I needed to modify it when I really didn't. Works fine if you drop it into your theme folder.
Comment #9
gautamb commentedThis was helpful but I'm having a small problem with it. It only displays 1 column. I have large table and I wanted 4 columns to be displayed. how can I modify it to display more than one?
Comment #10
eric.chenchao commentedHi Gautabmb,
I have found a practical way to present vertical table by using jquery plugin.
You can download this js script:
http://plugins.jquery.com/project/tabletransposeand write a simple custom module with the function, for example
Voila! And you can also use sorting function.
Cheers, Eric
Comment #11
kuroneko007 commentedHi cityreader,
This sounds like a perfect solution to the problem that I have been searching for a long time.
However, I'm still pretty much a Drupal n00b, could you explain where I should insert the php code you provided? I take it I don't need to add any script tags to load the plugin as this is done by your php code.
Thanks!
Comment #12
kuroneko007 commentedNever mind, I figured it out for myself. First time writing a custom module and first time using a jQuery plugin, but it works!
Just one thing, the above code wouldn't do anything until I removed the line
if (Drupal.jsEnabled) {....}Had me stuck for about 2 days, but I learned a lot in that time!
Edit: Turns out that the variable Drupal.jsEnabled has been removed since Drupal 7, so checking for this was giving me a FALSE every time.
Comment #13
drupalgambatte commentedI wonder if this kind of a hack is possible for a node display, perhaps a particular content type;
It is possible to define fields and list them all one below another as an unformatted list, but can we convert this long list of "field name" = "field value" array into a two column table so that it is displayed neatly and nicely,
Comment #14
naught101 commented@Merlin: An excellent use-case for vertical tables is for comparisons, where there are few nodes, with many fields:
https://www.ohloh.net/p/compare?project_0=Joomla!&project_1=WordPress&pr...
or
http://www.phonescoop.com/phones/compare.php?p=3541,3768
While that's probably not useful for generic, include-everything views, it would certainly be useful with nodequeue, flag, or relation-based views.
Note that table sorting is not usually relevant in these kind of tables, since there's so few entities being shown. Grid view doesn't work for this use-case, because the fields need to be side-by side, and they aren't if there are some fields missing from some nodes.
Comment #15
naught101 commentedhttps://drupal.org/project/views_hacks includes a module called "views_flipped_table" which works exactly as specified in the original post. Unfortunately the parent "module" is somewhat abandoned. The module appears to be pretty small, and well coded, although there are no tests. Is there any chance of it getting included in views? If so, I would be happy to do some work on getting into appropriate shape. What would be required?
Comment #16
naught101 commentedI have taken over maintainership of the views_flipped_table, which has been split off from views_hacks, and is now available at https://drupal.org/project/views_flipped_table.