You are here

function theme_video_customfields in Video 6

Same name and namespace in other branches
  1. 5 plugins/video_customfields/video_customfields.module \theme_video_customfields()

Display custom fields on the view page.

Parameters

$node: object with node information

Return value

string of content to display

1 theme call to theme_video_customfields()
video_customfields_nodeapi in plugins/video_customfields/video_customfields.module
Implementation of hook_nodeapi()

File

plugins/video_customfields/video_customfields.module, line 217
Enable addition of custom fileds on video nodes created by video module.

Code

function theme_video_customfields($node) {

  //Adds the custom fields.
  $group_title = variable_get('video_customfieldtitle', '');

  //Title of the custom fields.
  $title1 = variable_get('video_customfield1', '');
  $title2 = variable_get('video_customfield2', '');
  $title3 = variable_get('video_customfield3', '');
  $title4 = variable_get('video_customfield4', '');
  $title5 = variable_get('video_customfield5', '');
  $title6 = variable_get('video_customfield6', '');

  //Run the fields through the input filter set for the node, then remove paragraphs.

  //Removes the <p> and </p> tags from the filter pass return. This allows each field to be on one line.

  //A better system might be to remove only the first and last <p></P> tags.
  $field1 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_1, $node->format, FALSE));
  $field2 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_2, $node->format, FALSE));
  $field3 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_3, $node->format, FALSE));
  $field4 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_4, $node->format, FALSE));
  $field5 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_5, $node->format, FALSE));
  $field6 = str_replace(array(
    '<p>',
    '</p>',
  ), '', check_markup($node->custom_field_6, $node->format, FALSE));
  $output = '';

  //Make sure all the titles are not blank, if not then display them.
  if ($title1 . $title2 . $title3 . $title4 . $title5 . $title6 != '') {
    $output = '<div class="videofields">';

    //Enclose all output in "videofields" div class.
    if ($group_title != '') {
      $output .= '<div class="title"><h2>' . check_plain($group_title) . '</h2></div>' . "\n";
    }
    if ($title1 != '' and $node->custom_field_1 != '') {
      $fields[] = array(
        'title' => $title1,
        'body' => $field1,
      );
    }
    if ($title2 != '' and $node->custom_field_2 != '') {
      $fields[] = array(
        'title' => $title2,
        'body' => $field2,
      );
    }
    if ($title3 != '' and $node->custom_field_3 != '') {
      $fields[] = array(
        'title' => $title3,
        'body' => $field3,
      );
    }
    if ($title4 != '' and $node->custom_field_4 != '') {
      $fields[] = array(
        'title' => $title4,
        'body' => $field4,
      );
    }
    if ($title5 != '' and $node->custom_field_5 != '') {
      $fields[] = array(
        'title' => $title5,
        'body' => $field5,
      );
    }
    if ($title6 != '' and $node->custom_field_6 != '') {
      $fields[] = array(
        'title' => $title6,
        'body' => $field6,
      );
    }
    $output .= theme('video_fields', $fields);

    //Generate all the fields HTML.
    $output .= '</div><br />';

    //Close the "videofields" class div.
  }
  return $output;
}