It seems like Drupal is ignoring check_markup(). What is wrong with the code below?

print check_markup($node->body, 'microblog', TRUE);

Site's default input format filter is = 'Filtered HTML'. All users have access to the 'microblog' filter, but I see my 'microblog' filter is kind of not working, and it uses filtered HTML.

What am I doing wrong?

1 Answer 1


In Drupal 6, the second argument of check_markup() is the value of the "format" field in the "filter_formats" table; it is a serial field, which means it can contain only numbers.

The documentation for the function doesn't specify what you should pass; it uses a phrase that could be misunderstood, but it doesn't talk of format name.

$format The format of the text to be filtered. Specify FILTER_FORMAT_DEFAULT for the default format.

Looking at how the function is called in node_prepare(), I noticed the code that calls the function is the following one:

  if ($teaser == FALSE) {
    $node->body = check_markup($node->body, $node->format, FALSE);

The content of $node->format is always a number, in Drupal 6.

In a standard installation of Drupal 6, without any extra modules installed, these are the values for the format ID to pass to check_markup():

Format ID     Input format
1             Filtered HTML
2             Full HTML
3             PHP code

To get the format ID knowing the name (e.g. "Filtered HTML"), you should use code similar to the following one:

$format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $format_name));

The format ID required from the function is different from a filter ID: An input format is a set of input filters that are used together to filter out or change what entered from users. What the modules implement are input filters.

  • Thank you very much. But why in API documentation it says that you could use the name of the filter as $format? Commented Sep 3, 2011 at 15:02
  • The documentation says, "The format of the text to be filtered." It doesn't say to use the name of the format, but it doesn't specify exactly what you should pass too.
    – apaderno
    Commented Sep 3, 2011 at 15:04
  • Thanks for nice explaining this thing, really aprecciate that! Commented Sep 5, 2011 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.