function content_view_content

7.x content.module content_view_content($cid)
6.x content.module content_view_content($cid)
4.x content.module content_view_content()
5.x content.module content_view_content()

Display the content specified in the GET's cid.

File

modules/content/content.module, line 817

Code

function content_view_content($cid) {

  $render = array();
  $render ["#id"] = "content_" . $cid; // We will be doing this as a render array, so other modules can alter.
  $render ['#cid'] = intval($cid);

  fp_add_css(fp_get_module_path('content') . '/css/content.css');

  if (isset($_GET ['content_tabs']) && $_GET ['content_tabs'] == 'false') { // the string "false", not FALSE
    fp_add_body_class('content-tabs-false');
  }


  $content = content_load($cid); // assumed to be path/content/CID  So, arg(1) == the cid
  if (!$content) {
    // Couldn't find it!  Show page not found.
    display_not_found();
    return;
  }
  $render ['#content_object'] = $content;
  $type = $content->type;
  $types = content_get_types();
  $author = fp_load_user($content->user_id);

  $render ['#content-type'] = $type;

  $render ['#class'] = "content-type-" . $type;

  $weight = 0;


  if (!strstr($content->title, "[hide]")) {
    fp_set_title($content->title);
  }
  fp_add_body_class("content-type-" . $content->type);

  //$rtn .= "<div class='content-view content-view-{$content->type}'>";

  $render ['content_title'] = array(
    'type' => 'markup',
    'value' => "<div class='content-title'>" . $content->title . "</div>",
    'weight' => $weight,
  );



  $render ['content_submitted'] = array(
    'type' => 'markup',
    'value' => "<div class='content-submitted'>" . t("Submitted by") . " " . $author->name . " " . t("on") . " " . format_date(convert_time($content->updated), 'short') . "</div>",
    'weight' => $weight += 10,
  );

  if ($content->delete_flag == 1) {
    $render ['content_deleted'] = array(
      'type' => 'markup',
      'value' => "<div class='content-deleted'>" . t("NOTE: This content has been marked as deleted, and is scheduled for permanent removal.") . "</div>",
      'weight' => $weight += 10,
    );

  }


  // Display all the various fields
  if (is_array($types [$type]['fields'])) {
    foreach ($types [$type]["fields"] as $field_name => $field_details) {

      $display_value = $content->{"field__$field_name"}['display_value'];

      if ($field_details ['type'] != 'hidden' && $field_details ['type'] != 'cfieldset') {
        $render ['field__' . $field_name] = array(
          'type' => 'markup',
          'label' => $field_details ['label'],
          'value' => "<div class='field-value'>$display_value</div>",
          'weight' => $weight += 10,
        );

      }

      if ($field_details ['type'] == 'cfieldset') {
        // TODO:  make this appear within a fieldset?
        foreach ($field_details ['elements'] as $c => $v) {
          foreach ($field_details ['elements'][$c] as $efield_name => $edetails) {

            $display_value = $content->{"field__$efield_name"}['display_value'];

            if ($edetails ['type'] != 'hidden' && $edetails ['type'] != 'cfieldset') {
              $render ['field__' . $efield_name] = array(
                'type' => 'markup',
                'label' => $edetails ['label'],
                'value' => "<div class='field-value'>$display_value</div>",
                'weight' => $weight += 10,
              );
            }
          }
        }

      } // its a fieldset




    }
  }


  content_set_last_access($cid);


  if (isset($_GET ['content_crumbs'])) {
    if ($_GET ['content_crumbs'] == 'alerts') {
      $crumbs = array();
      $crumbs [] = array(
        'text' => 'Alerts',
        'path' => 'alerts',
      );
      fp_set_breadcrumbs($crumbs);
    }
  }


  watchdog("content", "view cid:$cid, type:$type", array());

  return fp_render_content($render);

}