0

I have a view which is rendered as a table, the last column is labeled "actions" which I display both the "Edit" and "Delete" links accordingly.

I need to implement a few more custom operations, I found this as a starting point:

Custom entity operation links

Here is what I have thus far:

module.module

<?php
  function module_views_api() {
    return array(
      'api' => 3,
      'path' => drupal_get_path('module', 'module') . '/views',
    );
  }

module.info

files[] = views/module.views.inc
files[] = views/module_handler_print.inc

module.views.inc

<?php

  function module_views_data() {
    $data = array();
    $data['node']['print'] = array(
      'title' => t('Print link'),
      'help' => t('Provide a simple link to print the content.'),
      'field' => array(
        'handler' => 'module_handler_print',
      ),
    );

    return $data;
  }

module_handler_print.inc

<?php
  class views_handler_field_node_link_print extends views_handler_field_node_link {

    function render_link($node, $values) {
      // Ensure user has access to edit this node.
      if (!node_access('update', $node)) {
        return;
      }

      $this->options['alter']['make_link'] = TRUE;
      $this->options['alter']['path'] = "node/$node->nid/print";
      $this->options['alter']['query'] = drupal_get_destination();

      $text = !empty($this->options['text']) ? $this->options['text'] : t('print');

      return $text;
    }

  }

I can see the option when adding the field to VIEWS but when I select it I get the error:

Configure field: Broken/missing handler

Any ideas???

  • Looks like I have to implement a views_handler_field_node_link similar to how views_handler_field_node_link_edit does...how do I register this handler though? – Alex.Barylski Oct 10 '14 at 17:29
  • try to extend views_handler_field class. – Codium Oct 10 '14 at 19:39
1

You can try this module: https://www.drupal.org/project/ccl

or create your custom solution based on this code snippet

  • ccl is pretty interesting...I literally just found the github code and pasted...no dice same error...I'll update my post with code thus far. – Alex.Barylski Oct 10 '14 at 19:16

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.