Hi

I have been using the node_example.module sample to learn a bit about writing drupal modules. I have run into a bit of a problem though with the node filters and I am hoping that a veteran developer could just clarify this issue for me.

The node_example.module has these two functions that are used to render the 'new' node:


function node_example_view(&$node, $teaser = FALSE, $page = FALSE) {
  $node = node_example_content($node, $teaser);
  return theme('node', $node, $teaser, $page);
}

function node_example_content($node, $teaser = FALSE) {
  $order_info = theme('node_example_order_info', $node);
  $node->body .= $order_info;
  $node->teaser .= $order_info;
  return node_prepare($node, $teaser);
}

function theme_node_example_order_info($node) {
  $output = '<div class="node_example_order_info">';
  $output .= t('The order is for %quantity, %colour items.', array('%quantity' => $node->quantity,
                                                                   '%colour' => $node->colour));
  $output .= '</div>';
  return $output;

node->body is themed by node_example_content() and then filtered through node_prepare. One of the things that the theme does in insert a

into the node body. The problem is that the filter then removes the
.

Now my problem is:
How do I use my theme to insert the

tags that I want, but still prevent users from submitting node bodies that contain
tags.

Any help/clarifications here would be greatly appreciated.

Comments

tristan’s picture

Sorry about the messy code above, but I couldn't figure out how to post the code nicely. I tried using the <code> tags, but they didn't seem to help very much.

Steven’s picture

Implement hook_view() and run only the user supplied content through check_output() (the filter system). Then add your own HTML.

amanda’s picture

This seems to be the problem with a module I am using. I submitted the issue, but would like to get this working.

http://drupal.org/node/15701

amanda’s picture

This seems to be the problem with a module I am using. I submitted the issue, but would like to get this working.

http://drupal.org/node/15701