You are here

function fasttoggle_node_fasttoggle_ajax_alter in Fasttoggle 7

Same name in this branch
  1. 7 fasttoggle.api.php \fasttoggle_node_fasttoggle_ajax_alter()
  2. 7 module/fasttoggle_node/fasttoggle_node.module \fasttoggle_node_fasttoggle_ajax_alter()

Hook allowing modification of the fasttoggle ajax result.

Parameters

array $ajax_commands: The default ajax commands (arg to ajax_render).

string $object_type: The type of object being handled.

object $object: An instance of the object that has been modified, as saved.

array $params: An array of further parameters, since drupal_alter only supports 3 parameters. The array contains the group, option and view strings that describe what option was toggled and what view (if any) was applied to the object in its original render.

File

./fasttoggle.api.php, line 220
Hooks provided by the Fasttoggle module.

Code

function fasttoggle_node_fasttoggle_ajax_alter(array &$ajax_commands, $object_type, $object, array $params) {
  if ($object_type != "node") {
    return;
  }

  // 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);
}