Wordfilter was working great for us in terms of node content, but one issue that cropped up was that we wanted to filter the titles of some nodes and not others. In our context, the criteria was whether or not the node body used a format that included the wordfilter filter. We're using Better Input Formats to help control the formatting of a few specific node types, and since wordfilter is a filter, it behaved just fine for the body.
Here is the change that I made to fix our specific issue. This approach may not be generic enough to fit every user case and so I offer this mostly to start the conversation of how, or even if, to conditionally filter node titles based on node format decisions.
function wordfilter_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'insert':
case 'update':
if (variable_get('wordfilter_node_title', TRUE)) {
if (db_result(db_query("SELECT fid FROM {filters} WHERE module = 'wordfilter' AND delta = 0 AND format = '%s'", $node->format))) {
$node->title = wordfilter_filter_process($node->title);
}
}
break;
case 'load':
if (variable_get('wordfilter_node_title', TRUE)) {
if (db_result(db_query("SELECT fid FROM {filters} WHERE module = 'wordfilter' AND delta = 0 AND format = '%s'", $node->format))) {
$node->title = wordfilter_filter_process($node->title);
}
}
break;
Comments
Comment #1
te-brian CreditAttribution: te-brian commentedQuick edit: Mixed up the type of `format` in my SQL
Comment #2
jaydub CreditAttribution: jaydub commentedlooks like a good idea. I think I'll look into just setting this as a variable rather than doing a query every time.
Comment #3
jaydub CreditAttribution: jaydub commentedI implemented a variation on what the original poster suggested.
http://drupal.org/cvs?commit=317944
http://drupal.org/cvs?commit=317942