[development] ckk markup module doesn't work for node view

Ernst Plüss ernst.pluess at gmail.com
Mon Apr 12 10:32:36 UTC 2010


Hi Drupal friends

I'm using the markup (http://drupal.org/project/markup) module to add
additional text to my cck forms. This works very nice for the forms.

Now I need this text for the node view as well. I tried to add a formatter
(which was completely missing) and changed the hook_is_emtpy to return TRUE.
But no luck, the formatters nor the hook_is_emtpy are ever called. The only
thing I got working is that I can choose one of my new formatters when
configuring cck.

It seams, that I'm missing something essential to get the markup module to
output the text for node view as well.
Any ideas are welcome.

Thank you for taking your time!
Ernst

This is my code:

<?php
// $Id: markup.module,v 1.2.2.1 2009/07/21 14:14:02 cyu Exp $

/**
 * @file
 * Defines a field type for displaying markup on the node/edit form.
 */

/**
 * Implementation of hook_field_info().
 */
function markup_field_info() {
  return array(
    'markup' => array('label' => 'Markup'),
  );
}

/**
 * Implementation of hook_field_settings().
 */
function markup_field_settings($op, $field) {
  switch ($op) {
    case 'form':
      $form = array();
      $form['markup'] = array(
        '#type' => 'textarea',
        '#title' => t('Markup'),
        '#default_value' => isset($field['markup']) ? $field['markup'] : '',
        '#required' => TRUE,
        '#rows' => 15,
        '#description' => t('The markup to be displayed. Any HTML is legal
here, so be careful not to break your page layout.'),
      );
      $form['instructions'] = array(
        '#type' => 'markup',
        '#value' => htmlentities(t('This is a special field. It will output
the markup below, unfiltered by the system, on the node/edit form for this
content type. Consider wrapping any visible output in <div
class="form-item"></div> to follow form standards.')),
        '#weight' => -1,
      );
      return $form;

    case 'validate':
      break;

    case 'save':
      return array('markup');

    case 'callbacks':
      return array(
        'view' => CONTENT_CALLBACK_CUSTOM,
      );

    case 'database columns':
      return array();
  }
}

/**
 * Implementation of hook_widget_info().
 */
function markup_widget_info() {
  return array(
    'markup' => array(
      'label' => 'Markup',
      'field types' => array('markup'),
      'multiple values' => CONTENT_HANDLE_MODULE,
    ),
  );
}

/**
 * Implementation of hook_content_multigroup_allowed_widgets().
 */
function markup_content_multigroup_allowed_widgets() {
  return array('markup');
}

/**
 * Implementation of hook_content_multigroup_no_remove_widgets().
 */
function markup_content_multigroup_no_remove_widgets() {
  return array('markup');
}

/**
 * Implementation of hook_widget().
 */
function markup_widget(&$form, &$form_state, $field, $items, $delta = 0) {
  $element = array(
    '#type' => 'markup',
    '#title' => '',
    '#value' => $field['markup']
  );
  return $element;
}

/**
 * Implementation of hook_form_alter().
 */
function markup_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'content_field_edit_form' && $form['module']['#value'] ==
'markup') {
    $form['widget']['label']['#description'] = t('This label is for internal
use. If you would like to put a headline on your form markup, you should put
HTML for that in the markup area itself.');
    // Remove non-applicable fields on the widget settings form.
    unset($form['widget']['description']);
    unset($form['field']['required']);
    unset($form['field']['multiple']);
    unset($form['field']['#description']);
  }
}

/**
 * Implementation of cck hook_content_is_empty().
 */
function markup_content_is_empty($item, $field) {
  return FALSE;
}

/**
 * Implementation of cck hook_field()
 */
function markup_field($op, &$node, $field, &$node_field, $teaser, $page) {
  switch ($op) {
    case 'view':
      $items = array();
      foreach ($node_field as $delta => $item) {
        $items[$delta]['view'] = content_format($field, $item, 'default',
$node);
      }
      return theme('field', $node, $field, $items, $teaser, $page);
      break;
  }
}

/**
 *Implementation of hook_field_formatter_info().
 *
 */
function markup_field_formatter_info() {
  return array(
    'nothing' => array(
      'label' => t("Don't show markup"),
      'field types' => array('markup'),
      'multiple values' => CONTENT_HANDLE_CORE,
    ),
    'all' => array(
      'label' => t("Show all markup"),
      'field types' => array('markup'),
      'multiple values' => CONTENT_HANDLE_CORE,
    )
    );
}

/**
 * Implementation of hook_theme().
 */
function markup_theme() {
  return array(
    'markup_formatter_nothing' => array(
      'arguments' => array('element' => NULL),
    ),
    'markup_formatter_all' => array(
      'arguments' => array('element' => NULL),
    ),
    );
}

/**
 * Theme a table.
 */
function theme_markup_formatter_nothing($element = NULL) {
  return "";
}

/**
 * Theme a table.
 */
function theme_markup_formatter_all($element = NULL) {
  return "ALL ALL ALL";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100412/482d7ad5/attachment-0001.html 


More information about the development mailing list