function fasttoggle_node_fasttoggle_ajax_alter in Fasttoggle 7
Same name in this branch
- 7 fasttoggle.api.php \fasttoggle_node_fasttoggle_ajax_alter()
- 7 module/fasttoggle_node/fasttoggle_node.module \fasttoggle_node_fasttoggle_ajax_alter()
Alter the ajax commands being returned to the browser.
Parameters
array $ajax_commands: The array of ajax commands being returned.
string $object_type: The type of object being modified.
object $object: The object instance.
array $params: Additional parameters.
File
- module/
fasttoggle_node/ fasttoggle_node.module, line 364
Code
function fasttoggle_node_fasttoggle_ajax_alter(array &$ajax_commands, $object_type, $object, array $params) {
if ($object_type != "node") {
return;
}
// If we don't know what view was used (fields don't), give our best guess.
if (!isset($params['view'])) {
$params['view'] = "full";
}
// Replace the original content with that the updated content, so far as we're
// able (we don't get it exactly right yet).
$unrendered = node_view($object, $params['view']);
if ($object->comment > 0 && module_exists('comment') && $params['view'] == 'full') {
$unrendered['comments'] = comment_node_page_additions($object);
}
$replacement_content = drupal_render($unrendered);
$ajax_commands[] = ajax_command_replace('.' . 'node-content-' . $object->nid, $replacement_content);
}