Hi Drupal friends<br><br>I'm using the markup (<a href="http://drupal.org/project/markup">http://drupal.org/project/markup</a>) module to add additional text to my cck forms. This works very nice for the forms.<br><br>
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.<br>
<br>It seams, that I'm missing something essential to get the markup module to output the text for node view as well.<br>Any ideas are welcome.<br><br>Thank you for taking your time!<br>Ernst<br><br>This is my code:<br>
<br><span style="font-family: courier new,monospace;"><?php</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">// $Id: markup.module,v 1.2.2.1 2009/07/21 14:14:02 cyu Exp $</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * @file</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Defines a field type for displaying markup on the node/edit form.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Implementation of hook_field_info().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_field_info() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'markup' => array('label' => 'Markup'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Implementation of hook_field_settings().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_field_settings($op, $field) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> switch ($op) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'form':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $form = array();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $form['markup'] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#type' => 'textarea',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#title' => t('Markup'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#default_value' => isset($field['markup']) ? $field['markup'] : '',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#required' => TRUE,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#rows' => 15,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#description' => t('The markup to be displayed. Any HTML is legal here, so be careful not to break your page layout.'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $form['instructions'] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#type' => 'markup',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#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.')),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#weight' => -1,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return $form;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'validate':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> break;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'save':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array('markup');</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'callbacks':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'view' => CONTENT_CALLBACK_CUSTOM,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'database columns':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Implementation of hook_widget_info().</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">function markup_widget_info() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'markup' => array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'label' => 'Markup',</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'field types' => array('markup'),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'multiple values' => CONTENT_HANDLE_MODULE,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Implementation of hook_content_multigroup_allowed_widgets().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_content_multigroup_allowed_widgets() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array('markup');</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Implementation of hook_content_multigroup_no_remove_widgets().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_content_multigroup_no_remove_widgets() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array('markup');</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Implementation of hook_widget().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_widget(&$form, &$form_state, $field, $items, $delta = 0) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $element = array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#type' => 'markup',</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#title' => '',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> '#value' => $field['markup']</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return $element;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Implementation of hook_form_alter().</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">function markup_form_alter(&$form, $form_state, $form_id) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ($form_id == 'content_field_edit_form' && $form['module']['#value'] == 'markup') {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $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.');</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> // Remove non-applicable fields on the widget settings form.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> unset($form['widget']['description']);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> unset($form['field']['required']);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> unset($form['field']['multiple']);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> unset($form['field']['#description']);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Implementation of cck hook_content_is_empty().</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">function markup_content_is_empty($item, $field) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return FALSE;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Implementation of cck hook_field()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">function markup_field($op, &$node, $field, &$node_field, $teaser, $page) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> switch ($op) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> case 'view':</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $items = array();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> foreach ($node_field as $delta => $item) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $items[$delta]['view'] = content_format($field, $item, 'default', $node);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return theme('field', $node, $field, $items, $teaser, $page);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> break;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> *Implementation of hook_field_formatter_info().</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> *</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function markup_field_formatter_info() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'nothing' => array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'label' => t("Don't show markup"),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'field types' => array('markup'),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'multiple values' => CONTENT_HANDLE_CORE,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'all' => array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'label' => t("Show all markup"),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'field types' => array('markup'),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'multiple values' => CONTENT_HANDLE_CORE,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> * Implementation of hook_theme().</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">function markup_theme() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'markup_formatter_nothing' => array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'arguments' => array('element' => NULL),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'markup_formatter_all' => array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'arguments' => array('element' => NULL),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Theme a table.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function theme_markup_formatter_nothing($element = NULL) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return "";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/**</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> * Theme a table.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function theme_markup_formatter_all($element = NULL) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return "ALL ALL ALL";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br>