Created
February 1, 2012 22:01
-
-
Save dergachev/1719744 to your computer and use it in GitHub Desktop.
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
<?php | |
// menu callback that returns NULL, used for web services | |
function article_callback_json($node) { | |
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); | |
print json_encode($arr); // {"a":1,"b":2,"c":3,"d":4,"e":5} | |
return NULL; | |
} | |
//menu callback that returns a string for Drupal to wrap in the page layout | |
function article_callback_string($node) { | |
return "<h2>" . $node->title . "</h2> <div>" . $node->body . "</div>"; | |
} | |
//menu callback that returns a renderable array for Drupal to render | |
function article_callback_array($node) { | |
return array( | |
'#theme' => 'node_article', | |
'#article_title' => $node->title, | |
'#article_body' => $node->body, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment