Drupal 7 - Using Ctools modal popup node view with comments

<?php
/**
 *  Implements of hook_menu() 
*/
function hook_menu() {
  $items = array();
  $items['pop/%ctools_js/%'] = array(
    'page arguments' => array(1, 2),
    'page callback' => 'pop_modal_page',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function pop_modal_page($js = NULL, $nid) {
  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');
  } else return 'Your browser does not support javascript';

  $node = node_load($nid);
  $node_view = node_view($node);
  $node_view['comments'] = comment_node_page_additions($node);
  $contents = render($node_view); 
  return ctools_modal_render($node->title, $contents) ;
}

Tags

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.