2

I'm using views to create a list of nodes grouped by a field. The problem is that, in the html output, I've something like this:

<h3>Group title</h3>
<div class="view-row">content..</div>
<div class="view-row">content..</div>

<h3>Group title</h3>
<div class="view-row">content..</div>
<div class="view-row">content..</div>

I've put the group title and its contents in a common div, but which template do I have to work on?

1

2 Answers 2

1

Theming views can be done in a number of files. For best assistance I suggest in views you look at the "Theme Information" option. It can be found at {drupal site}/admin/structure/views/nojs/display/{view name}/page/analyze-theme (It's under the right hand side "Advanced" column).

On that screen you will find a list of all the files that you Drupal will look for to theme for the view concerned, ranging from the very specific (views-view-fields--{view-name}--{display-name}.tpl.php for row styling) to a slightly more generic views-view.tpl.php (Covers every view) You can drill further down depending on what your view selects (Fields, Rendered Entity, Display Suite content etc) but the Theme information link shown above should provide you with a list of every file that you can provide to Drupal for theming.

Remember to flush your cache when you add a new theming file so Drupal knows about it.

4
  • I use always these files, template.php and so on :) The problem is that, in .tpl files, I can't found information about groups, however I'll try :)
    – arrubiu
    Commented Mar 23, 2013 at 11:41
  • 1
    In that case does this answer help you? Commented Mar 24, 2013 at 10:32
  • exactly, I've do in this way before your message ;) thanks!
    – arrubiu
    Commented Mar 24, 2013 at 14:04
  • This isn't helpful since the question is directly related to groups which that option doesn't actually ofer tragically Commented Jun 29, 2016 at 0:50
0

On the Theme Information views page you can find the views-view-unformatted--{view-name}.tpl theme sugestion that handles that specific code. It is just a matter of coping the file from the views module folder to the templates folder of your theme and override it.

<?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>
  </div>
<?php endforeach; ?>

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.