Hi Drupal friends<br><br>I&#39;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&#39;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;">&lt;?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;">    &#39;markup&#39; =&gt; array(&#39;label&#39; =&gt; &#39;Markup&#39;),</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 &#39;form&#39;:</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[&#39;markup&#39;] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;#type&#39; =&gt; &#39;textarea&#39;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        &#39;#title&#39; =&gt; t(&#39;Markup&#39;),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;#default_value&#39; =&gt; isset($field[&#39;markup&#39;]) ? $field[&#39;markup&#39;] : &#39;&#39;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        &#39;#required&#39; =&gt; TRUE,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;#rows&#39; =&gt; 15,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        &#39;#description&#39; =&gt; t(&#39;The markup to be displayed. Any HTML is legal here, so be careful not to break your page layout.&#39;),</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[&#39;instructions&#39;] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;#type&#39; =&gt; &#39;markup&#39;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        &#39;#value&#39; =&gt; htmlentities(t(&#39;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 &lt;div class=&quot;form-item&quot;&gt;&lt;/div&gt; to follow form standards.&#39;)),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;#weight&#39; =&gt; -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 &#39;validate&#39;:</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 &#39;save&#39;:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      return array(&#39;markup&#39;);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    case &#39;callbacks&#39;:</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;">        &#39;view&#39; =&gt; 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 &#39;database columns&#39;:</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;">    &#39;markup&#39; =&gt; array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;label&#39; =&gt; &#39;Markup&#39;,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      &#39;field types&#39; =&gt; array(&#39;markup&#39;),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;multiple values&#39; =&gt; 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(&#39;markup&#39;);</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(&#39;markup&#39;);</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(&amp;$form, &amp;$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;">    &#39;#type&#39; =&gt; &#39;markup&#39;,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    &#39;#title&#39; =&gt; &#39;&#39;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    &#39;#value&#39; =&gt; $field[&#39;markup&#39;]</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(&amp;$form, $form_state, $form_id) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  if ($form_id == &#39;content_field_edit_form&#39; &amp;&amp; $form[&#39;module&#39;][&#39;#value&#39;] == &#39;markup&#39;) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    $form[&#39;widget&#39;][&#39;label&#39;][&#39;#description&#39;] = t(&#39;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.&#39;);</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[&#39;widget&#39;][&#39;description&#39;]);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    unset($form[&#39;field&#39;][&#39;required&#39;]);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    unset($form[&#39;field&#39;][&#39;multiple&#39;]);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    unset($form[&#39;field&#39;][&#39;#description&#39;]);</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, &amp;$node, $field, &amp;$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 &#39;view&#39;:</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 =&gt; $item) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        $items[$delta][&#39;view&#39;] = content_format($field, $item, &#39;default&#39;, $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(&#39;field&#39;, $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;">    &#39;nothing&#39; =&gt; array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      &#39;label&#39; =&gt; t(&quot;Don&#39;t show markup&quot;),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;field types&#39; =&gt; array(&#39;markup&#39;),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      &#39;multiple values&#39; =&gt; 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;">    &#39;all&#39; =&gt; array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;label&#39; =&gt; t(&quot;Show all markup&quot;),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      &#39;field types&#39; =&gt; array(&#39;markup&#39;),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;multiple values&#39; =&gt; 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;">    &#39;markup_formatter_nothing&#39; =&gt; array(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      &#39;arguments&#39; =&gt; array(&#39;element&#39; =&gt; 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;">    &#39;markup_formatter_all&#39; =&gt; array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      &#39;arguments&#39; =&gt; array(&#39;element&#39; =&gt; 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 &quot;&quot;;</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 &quot;ALL ALL ALL&quot;;</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>