Drupal 7

Creating a Link on a Product Display Node to Edit a Referenced Product

Drupal Commerce is amazing. On a recent project I had the pleasure of working with it for the first time. I understood the link between products and product displays, but there were a few things that bothered me about the relationship. This example demonstrates a simple administrative UI modification to make it easier to edit a product display node's referenced product.

Disabling the "Read more" link if specific conditions are met

Here's a simple way to remove the Read more link at the module level (in Drupal 7).
Sometimes this is preferred over doing it at the theme level (because maybe we don't want the link to appear no matter what theme is being used).

/**
 * Implementation of hook_node_view().
 */
function mymodule_node_view($node, $view_mode) {
  // Remove the "Read more" links on Registrant Form teasers
  if ($node->type == 'regform' && $view_mode == 'teaser') {
    unset($node->content['links']['node']['#links']['node-readmore']);
  }
}
Tags: