从Drupal节点移除样式标记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Drupal节点移除样式标记相关的知识,希望对你有一定的参考价值。

A simple script to run with [drush](http://drupal.org/project/drush) to clean all Drupal nodes containing style tags.
  1. <?php
  2.  
  3. $results = db_query("SELECT DISTINCT nid from node_revisions WHERE body REGEXP '<style>.*</style>' OR body REGEXP '<style>.*</style>'");
  4.  
  5. while($nid = db_result($results)) {
  6. $node = node_load($nid);
  7. unset($node->teaser);
  8. $node->body = preg_replace('@<style[^>]*?>.*?</style>@siu', '',$node->body);
  9. node_save($node);
  10. }
  11. ?>

以上是关于从Drupal节点移除样式标记的主要内容,如果未能解决你的问题,请参考以下文章