Having heck of a time getting plugin to work.

Events happening in the community are now at Drupal community events on www.drupal.org.
reubenavery's picture

Hello all.
I'm having a good amount of difficulty in getting a style plugin to work and I was hoping I might get a little guidance from you good folks.

Working from the instructions at http://groups.drupal.org/node/10129, I put together the following.

first, in the module cp_helper.module:

<?php
function cp_helper_views_api() {
 
$api = array(
   
'api' => 2,
   
'path' => drupal_get_path('module', 'cp_helper').'/views'
 
);
  return
$api;
}
?>

I then created views/cp_helper.views.inc:

<?php
function cp_helper_views_plugins()
  return array(
   
'row' => array(
     
'cp_thumbs' => array(
       
'title' => t('CP Thumbnails'),
       
'help' => t('Displaying each node as a thumbnail'),
       
'handler' => 'views_view_row_cp_thumbs',
       
'parent' => 'cp_helper',
       
'theme' => 'views_view_row_cp_thumbs',
       
'uses fields' => FALSE,
       
'uses options' => FALSE,
      )
    ),
  );
}

function
template_preprocess_views_view_row_cp_thumbs(&$vars) {
 
krumo('i got here');
}
?>

and views/views_plugin_row_cp_thumbs.inc:

<?php
class views_plugin_row_cp_thumbs extends views_plugin_row {
  function
init(&$view, &$display, $options = NULL) {
   
krumo('view handler init');
  }
  function
render() {
   
krumo('view handler render');
    return
theme($this->theme_functions(), $this->view, $this->options, $rows);
  }
}
?>

I also created views/views-view-row-cp-thumbs.tpl.php..

Anyway, so with the above I can successfully select CP Thumbnails as a row style for my view. However, rendering the view returns zilch. Those krumo debug statements, the only one that gets hit is the one in hook_views_plugins. I have also determined that views_plugin_row_cp_thumbs.inc never gets included, nor is template_preprocess_views_view_row_cp_thumbs never invoked.

I know that the query is returning valid results, the only thing the view outputs is a multiple page pager.

It would be very helpful actually if there were a functioning style plugin module that I could learn from. Been trying to figure out whats going on in views.module but it's too smart for my tired old brain to decypher. ;)

I would appreciate any tips.. Been banging my head on this one.

Many thanks
Reuben

Comments

Also wanted to mention, I

reubenavery's picture

Also wanted to mention, I keep getting these errors throughout the site:

* warning: include_once(sites/all/modules/cp/cp_helper/cp_helper.views.inc) [function.include-once]: failed to open stream: No such file or directory in /Users/reuben/Sites/crushedplanet.com/includes/theme.inc on line 286.
* warning: include_once() [function.include]: Failed opening 'sites/all/modules/cp/cp_helper/cp_helper.views.inc' for inclusion (include_path='.:/usr/local/php5/lib/php') in /Users/reuben/Sites/crushedplanet.com/includes/theme.inc on line 286.
* warning: include_once(sites/all/modules/cp/cp_helper/cp_helper.views.inc) [function.include-once]: failed to open stream: No such file or directory in /Users/reuben/Sites/crushedplanet.com/includes/theme.inc on line 286.
* warning: include_once() [function.include]: Failed opening 'sites/all/modules/cp/cp_helper/cp_helper.views.inc' for inclusion (include_path='.:/usr/local/php5/lib/php') in /Users/reuben/Sites/crushedplanet.com/includes/theme.inc on line 286.

Why is it trying to include cp_helper/cp_helper.views.inc? I can't figure it out.. It actually is including the proper cp_helper/views/cp_helper.views.inc, at the same time this error is thrown up, strangely.

I think you have to configure

pcambra's picture

I think you have to configure the options path and theme path in the hook_views_plugins():

<?php
function cp_helper_views_plugins() {
 
$path = drupal_get_path('module', 'cp_helper') . '/views';
  return array(
   
'row' => array(
     
'cp_thumbs' => array(
       
'title' => t('CP Thumbnails'),
       
'help' => t('Displaying each node as a thumbnail'),
       
'handler' => 'views_view_row_cp_thumbs',
       
'path' => $path,
       
'parent' => 'cp_helper',
       
'theme' => 'views_view_row_cp_thumbs',
       
'theme path' => $path,
       
'uses fields' => FALSE,
       
'uses options' => FALSE,
      )
    ),
  );
}
?>

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: