开发者

Drupal module to manipulate every node's body

开发者 https://www.devze.com 2022-12-23 06:07 出处:网络
After importing content from a legacy website using the Feeds module, I\'m left with node bodies that contains links back to the old website.

After importing content from a legacy website using the Feeds module, I'm left with node bodies that contains links back to the old website.

Is there a Drupal module that will perform a one-time process to iterate through each node, manipulating the content of nodes using开发者_高级运维 some custom code?


You could easily write a PHP script to step through the node_revisions table and do your processing there. If you're comfortable with custom code, it's probably the fastest way.


You could write your own module with the intent of running it once. There is a Drupal hook_init() you can utilize to fire code when a module is on, and the page is loaded up. Within that function, you can query against all the nodes in the node table with db_query, iterate over each node and do a preg_replace on the link you want to change. After modifying the $node object, use node_save($node) at the end of the loop to save the node changes.

Alternatively, you can use a module like Link Checker, Path Redirect and/or Global Redirect to link old paths to new ones and look for busted links.


I usually run an SQL query in phpMyAdmin. See my post on http://drupal.org/node/718700#comment-2616682.


A late answer, but nevertheless. There is a pathologic module which can be used to fix links in nodes. For example, to make them absolute or to rewrite host part.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号