0

I am trying to override views-view-field.tpl.php in my custom module as suggested in override views-view-fields.tpl.php in custom module but looks like it's syntaxes are old.

My codes are like:

In mymodule.info

 ; $Id$

  name = My Module
  description = Create custom views template.
  package = Views
  dependencies[] = views
  core = 7.x

  files[] = mymodule.module
  files[] = includes/mymodule.views.inc

 ; Information added by drupal.org packaging script on 2011-07-21
  version = "7.x-4.1"
  core = "7.x"
  project = "mymodule"
  datestamp = "1311290520"

In mymodule.module

function mymodule_views_api() {
  return array(
   'api' => 3.0,
   'path' => drupal_get_path('module', 'mymodule') . '/includes',

   );
 }


function mymodule_theme($existing, $type, $theme, $path) 
  {

   return array(
    'views_view_field__views__ticker' => array(
    'variables' => array('view' => NULL, 'options' => NULL,'row' =>NULL),
    'template' => 'views-view-field--views--ticker',
    'base hook' => 'views_view_field',
    'path' => drupal_get_path('module', 'mymodule') . '/includes',

         ),
       );
    }

In /mymodule/includes/mymodule.views.inc

  function theme_views_view_field__views__ticker($vars) {

    $view = $vars['view'];
    $field = $vars['field'];
    $row = $vars['row'];

    return $vars['output'];
   }

  function template_preprocess_views_view_field__views__ticker(&$vars)       
   {

    $vars['output'] = $vars['field']->advanced_render($vars['row']);
   }

My custom template file views-view-field--views--ticker.tpl.php in /mymodule/includes

 <?php print $output; ?>

Problem: it is not overriding views-view-field.tpl.php

I am using drupal version 7.41

  • do you clean the cache? – Adrian Cid Almaguer Jan 18 '16 at 23:47
  • Yes,I did everytime.I believe in my code theme_hook is not propery configured,it is not detecting base hook I guess. – Hiranya Sarma Jan 19 '16 at 4:55
0

You should add the template file on your module info file:

; $Id$

name = My Module
description = Create custom views template.
package = Views
dependencies[] = views
core = 7.x

files[] = mymodule.module
files[] = includes/mymodule.views.inc
files[] = includes/views-view-field--views--ticker.tpl.php

; Information added by drupal.org packaging script on 2011-07-21
version = "7.x-4.1"
core = "7.x"
project = "mymodule"
datestamp = "1311290520"
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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