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?
Am I anywhere near the mark, or would the proposed cron method have to do a lot more (ignoring any of the time related issues)
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
On Fri, 14 Jan 2005, Mark Quinn wrote:
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?
Am I anywhere near the mark, or would the proposed cron method have to do a lot more (ignoring any of the time related issues)
The Really Simple Solution(tm) is to invalidate all filter caches at midnight. Drupal will then regenerate the filtered output when the node is accessed the next time.
Cheers, Gerhard