Created
June 12, 2012 23:16
-
-
Save ao5357/2920757 to your computer and use it in GitHub Desktop.
Nodes as json, etc. in D6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = JSON Nodes | |
description = Lets you print nodes as json for ctools, or some other formats | |
dependencies[] = ctools | |
package = Chaos tool suite | |
core = 6.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_menu() | |
*/ | |
function jsonodes_menu(){ | |
$items['plain/%/node/%node'] = array( | |
'title' => 'Node', | |
'page arguments' => array(1,3), | |
'access arguments' => array('access content'), | |
'page callback' => 'jsonodes_node_plain_callback', | |
'type' => MENU_CALLBACK | |
); | |
return $items; | |
} | |
/** | |
* Menu callback to display nodes plain (mostly for modals) | |
*/ | |
function jsonodes_node_plain_callback($nojs = NULL, $node) { | |
if(!node_access('view', $node)){ | |
drupal_access_denied(); | |
return; | |
} | |
$themed_node = node_view($node); | |
switch ($nojs) { | |
case 'ajax': | |
ctools_include('modal'); | |
print ctools_modal_render($node->title, $themed_node); | |
break; | |
case 'nojs': | |
drupal_goto(drupal_lookup_path('alias', 'node/' . $node->nid)); | |
break; | |
default: | |
drupal_set_title($node->title); | |
print $themed_node; | |
} | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment