0

I've had a few requests to find the pages where class "X" is being used and tried using the search function included in Drupal.

The search seems to only go through the text of a node, and not the HTML of the body field.

Is it possible to do this? Is there a module that has this kind of functionality? Or do I pretty much need to do a db_query on the body field of all nodes to find it?

A module or baked-in ability to find HTML would really save me some time if you're aware of any. D6 and D7 answers are appreciated.

Thanks!

4

1 回答 1

0

您无法使用标准搜索找到您要查找的内容,因为 Drupal 对已从大多数 HTML 内容中清除的索引内容执行搜索。你可以在这里看到它的实际效果:

https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_index/6

  // Strip off all ignored tags to speed up processing, but insert space 
  // before/after them to keep word boundaries.
  $text = str_replace(array('<', '>'), array(' <', '> '), $text);
  $text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>');

这适用于 Drupal 6 和 7。

您可以在此处阅读有关索引的更多信息:http ://www.acquia.com/blog/drupal-search-how-indexing-works

至于你问题的第二部分 - 我找不到任何搜索 HTML 的自定义模块,所以我认为你最好的选择是编写自己的模块并查询所有节点的主体。

于 2013-08-14T13:15:16.580 回答