My module colorbox_node_view_link Quick view materials in a Colorbox popup window

Drupal: 

When you need to view some nodes, pages in pop-up window, the module Colorbox Node helps. If you want to add a button "Quick view" to the teasers use this hook_node_view().
This module adds a link with class "colorbox-node" to the teasers of certain types. Result site visitors will work with your site faster and more convenient. Popup window is pretty, quick and beautifull.

This problem arises in the online stores for quick viewing of products or related products, or the need to speed up pages load for viewing a lot of text or video on your website. In any case, the acceleration opening pages thus create a favorable impression of your site.

colorbox_node_view_link.module
  1. /*add the link Quick view to teasers of node types blog, foto */
  2.  
  3. function colorbox_node_view_link_node_view($node, $view_mode, $langcode) {
  4.  
  5. if ( ($node->type=="blog") || ($node->type=="video") ) {
  6. if ($view_mode == 'teaser') {
  7. $node->content['quick_view'] = array(
  8. '#markup' => '<a href="'. url('node/' . $node->nid ).'" class="colorbox-node">'. t('Quick view').'</a>',
  9. '#weight' => 10,
  10. );
  11. }
  12. }
  13. }

In the module we have limited the types of materials to check the type of material: blog, or video. So you can add your own, or remove this check, then any teaser will have the desired class. After creating such links Quick View with colorbox-node class node reveals a pop-up window. To convert a string, use the Quick View configuration - interface translation - Translation and add this translation.

Translated from russian by Google Translate, bit corrected by tlito.

Modules: 
Category: