0

The Views preview of my table looks like this. enter image description here

Using Open Outreach it appears like this. enter image description here

Neither are exactly what I'd like to see. How can I change the displayed table format (on my site) without fooling with php and CSS? I'm new to Drupal. I really don't want to get into CSS and php.

3
  • You can't - CSS is what you use to style HTML, Drupal or not. You don't need any PHP knowledge for that, though
    – Clive
    Jul 17, 2015 at 12:52
  • I hesitate to comment because of the prior comment from "El maestro", but I do so anyway. To respond to it with something like "Yes we can" ... refer to my answer why I say so ... Jul 17, 2015 at 13:07
  • I just assumed that "neither are exactly what I'd like to see" meant the OP wasn't happy with how the table looks. To change how it looks, you need CSS. To change how it functions, I'm sure there are many things you could do. @Sam, What exactly would you like to see? I fear this question will end up closed as too broad or unclear without that information
    – Clive
    Jul 17, 2015 at 17:08

1 Answer 1

0

You could transform the tabular display by using the DataTables module, which uses the datatables plugin.

In doing so, you get all the typical dataTables widgets available, such as sorting for appropriate columns, but also a search box, pagination, etc.

Here is an excerpt from the module's project page:

... integrates the jQuery plugin DataTables into Drupal as a views style and a callable theme function. DataTables lets you add dynamic features to tables, including:

  • Variable length pagination
  • On-the-fly filtering
  • Sorting with data type detection
  • Smart handling of column widths
  • ... (1)

(1) = there are more features (i.e. "Themeable by CSS"), but that requires "fooling with php and CSS" ...

PS: Works great for both D6 and D7 ...

Update (related to that issue you ran into as mentioned in your comment):

Consider reviewing/testing if that patch in comment nr 1 might work for you. The patch looks like so:

diff --git a/datatables.module b/datatables.module
index 193c892..3b66932 100644
--- a/datatables.module
+++ b/datatables.module
@@ -244,11 +244,8 @@ function theme_datatable($variables) {
 function template_preprocess_datatables_view(&$vars) {
   // Run views table preprocess function to handle putting rows in columns,
   // classes, etc.
-  template_preprocess_views_view_table($vars);
-
-  // No need to add anything if there are no rows.
-  if (!$vars['rows']) {
-    return;
+  if(!empty($vars['rows'])) {
+    template_preprocess_views_view_table($vars);
   }
 
   $view     = $vars['view'];

The most elegant / straight forward way to "apply" that patch is to use GIT. However, this seems like only a few lines in 1 module are changed by the fix. You could also "apply" that fix by simply editing that module to be patched, by reading what the patch content is, and then editing the module with your favorite editor, to achieve the same result. Here are the steps involved:

  • navigate to the folder in your site that contains file datatables.module.
  • make a backup copy, eg to something like datatables.module.backup.
  • open datatables.module in your favorite editor, and scroll to the line around line 244. If you can, turn line numbers on.
  • You should then see a few lines of code identical to the lines near the top of the patch (not preceeded by '-' or '+' signs.
  • around line 247, there should be a line like template_preprocess_views_view_table($vars);, but without that '-' sign as in the patch
  • DELETE that exact line, and then next 4 lines entirely (which is indicated in the patch with the '-' sign at the start of each line).
  • then INSERT those 2 lines preceeded by a "+" in the patch (but make sure to replace the "+" signs at the start of those 2 lines with a blank).
  • save your (module) file, and rerun your test to see what effect/result you now get.
  • after you finished testing it, decide what you want to do with this edited version of the module. Continue to use it? If not rename the edited file to something like datatables.module.edited, and then rename the datatables.module.backup file back to datatables.module. That will have restored the original version.
9
  • OP has stated without fooling with php and CSS?, you've quoted Themeable by CSS. This doesn't answer the question unfortunately
    – Clive
    Jul 17, 2015 at 12:59
  • @Clive : you're right, but would you agree that with the (1) footnote I added it somehow makes that clear now? Jul 17, 2015 at 13:05
  • Sorry I'm not with you - so what part of that module lets you style tables without using css?
    – Clive
    Jul 17, 2015 at 13:32
  • Part of the question states "How can I change the displayed table format ... without fooling with php and CSS". My point (and answer) is that using (= install + enable module) DataTables, no PHP or CSS 'fooling' is needed to somehow address the "Neither are exactly what I'd like to see"-part of the question. Do you want me to add some links to online samples where we used it ... with no CSS edits at all? Jul 17, 2015 at 13:44
  • Thanks for the recommendation. I am new to Drupal. It has a long learning curve. If I can avoid having to learn CSS I can get my site working faster. I installed DataTables, but it throws an error message as documented here drupal.org/node/2514094#comment-10129186. I posted my particular version of the problem at that site and am waiting for a fix. Jul 17, 2015 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.