I am creating a recurring events views page, but currently the output of my view is displaying multiple references of the same date event. I am also not using Fields as an output, I am using content|teaser.

I have come up with 2 methods of resolving this issue, but wanted to clarify which is best and how to go about it.

  1. Find a hook that outputs the Views rows and then write a conditional to compare each row and delete the duplicates.

  2. Create a tpl file and do a preg_replace() on the views output to delete duplicate rows of the same data.

Now the question is how do i go about finding this hook or what to name the Views tpl file as? I only want it specific to this events page.

enter image description here

4 Answers 4


Views Template Suggestion

All views templates can be overridden with a variety of names, using the view, the display ID of the view, the display type of the view, or some combination thereof.

Below are different template suggestions you can use for overriding the defaults.

Let consider a example View, named foobar. Style: unformatted. Row style: Fields. Display: Page.

Display output: This controls the structure of the overall view, including the position of and code around the view administrative links, header, exposed filters, pager, "more" link, footer and feed icon. This template also controls the position of and code around the primary view content, empty content, and attached views.


Style output: This controls the structure of this particular view display's style, e.g. HTML List, Table, Unformatted, etc. This includes the view title and the code surrounding each row (item in your view) of the given style.


Row style output: This controls the internal structure of each row (item in your view), including the label and the content for each field.


Fields: There will be one entry for each field in your display, allowing you to control the structure and code for each. If your row style is set to "Node," there won't be any field entries, and the view will use the node's template file instead.

Lets take you have added Title field in the field list, then below are the suggestion to theme title field


Views Preprocessors suggestion If you want to alter the display of any view with preprocess functions, then you can use the below suggestions to modify the display of any view.

Views Preprocess suggestions

Altering Views result To alter the result of the view itself(i.e modifying the results before its being rendered) you can use any of the following hook,

For using these hooks, you can refer the answer by jimajamma.


  • 1
    Yep. And you can easily find (and add/change) the templates used by the View by clicking on the Theme: Information link in the Views UI.
    – Jimajamma
    Commented Jul 24, 2013 at 13:08

To use a specialized template, name the template file "views-view-youreventsview.tpl.php" where youreventsview is the name of your view.

  • which views tpl do i copy from the views folder? Commented Jul 24, 2013 at 15:08
  • I usually start with views-view-unformatted.tpl
    – adam_bear
    Commented Jul 24, 2013 at 16:55

The hook you are most probably looking for is views_pre_render(), eg, something along the lines of...

function YOURMODULE_views_pre_render(&$view) {

  if ($view->name == 'THE_VIEW_YOU_ARE_LOOKING_FOR') {

    // modify $view->result per whatever logic you require



...where $view->result is an array of all the rows in your View. Given that you are displaying nodes instead of fields in your View, this should just be an array of objects pointing to nids, eg, something like this:

  [0] => stdClass Object
        [nid] => 1

  [1] => stdClass Object
        [nid] => 2

  [2] => stdClass Object
        [nid] => 3

  [3] => stdClass Object
        [nid] => 18

I know this is an old thread. But if anyone is struggling to theme the admin views, it will be helpful.

To theme admin view, if we simply goto Theme: Information and create the suggested template file in our template folder of the theme, views won't simply pick up them for the themes like seven or Adminimal Theme. And it is not a good idea to modify the contributed themes also.

So, what will be the solution?

It is so simple...!

We can implement hook_views_api in a custom module.

 * Implements hook_views_api().
function mymodule_views_api() {
  $path = drupal_get_path('module', 'mymodule');
  return array(
    'api' => 3,
    'template path' => $path . '/templates',

Once you have cleared the drupal cache, views will start looking into the module's templates folder and will apply the defined templates.

I've written a detailed explanation here.

All done.

Enjoy the theme!.

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.