[drupal-support] Applying filter(s) to a node upon cron
Steven Wittens
steven at acko.net
Fri Jan 14 17:23:41 UTC 2005
Mark Quinn wrote:
>Hi all,
>
>I have a "page" node on my corporate intranet that contains deadlines
>and other date information. I've developed a filter which "lives
>inside" the html filter so that deadlines that are approaching or
>overdue are rendered in a different style to highlight them.
>
>Now, of course, this filter will only run on the node's body when the
>node is updated. I would like to update the node each night from a
>cron hook.
>
>I understand I can load the node with: $node = node_load( $nid => x );
>manipulate the body by setting $node->body
>and save the node with node_save( $node );
>
>But i'm lost on how to apply the filters. How is this done?
>
Filters are applied on output, not on input. However, there is a filter
cache which keeps the last filtered version of a piece of text to
prevent it from being reprocessed every time. The easiest way to force a
piece of text to be refiltered it to delete its entry from the filter
cache. The next time someone views it, it will be refiltered. This
requires you to hash the body and use it as an index into the cache, see
check_output() for the details.
However, it sounds like filters are not what you need. The filter system
is there to transform user-supplied content to HTML. It should not be
used to add new info or meta-info, especially not when it's only for
nodes, as the filter system is used for many more things than just nodes
(comments, profile fields, private messages, aggregated content, ...).
In fact, if I were you, I'd implement all this in the theme rather than
the filter system.
Steven Wittens
More information about the drupal-support
mailing list