You are here

function field_weight_process_field_weight_display_overview in Field display weights (per node) 7.2

Implements hook_process_node().

File

./field_weight.module, line 554
Field display weight module.

Code

function field_weight_process_field_weight_display_overview(&$variables) {

  // @todo: Expose setting in UI for this.
  if (module_exists('beautytips') && variable_get('field_weight_show_field_previews', TRUE)) {
    $node = $variables['form']['#node']['#value'];
    $build = node_view($node, 'full', $node->language);
    if ($build) {

      // Alright! Go through the instances and put the rendered value of stuff
      // into BeautyTips on the relevant id element from the template.
      $beautytips_popups = array();
      foreach (array_keys($variables['instances']) as $instance_name) {
        if (isset($build[$instance_name])) {
          $rendered_instance = drupal_render($build[$instance_name]);
          $beautytips_popups["field_weight_{$instance_name}"] = array(
            'cssSelect' => "#row-{$instance_name} .field-element",
            'text' => $rendered_instance,
            'shrinkToFit' => TRUE,
            'fill' => 'white',
          );
        }

        // Let other modules alter how our BeautyTips look.
        // They can also just implement hook_define_beautytips_styles(),
        // but if they want to change the text (for example) then they
        // need this.
        $hook = __FUNCTION__;
        drupal_alter('field_weight_preview_popups', $beautytips_popups, $variables, $hook);
        beautytips_add_beautytips($beautytips_popups);
      }
    }
  }
}