I am a Drupal newbie and I am frustrated in my search for methods that allow admin searches of code in node content fields ie CSS classes. I'm baffled that there is not a built-in default way to help admins search content like this.

I have looked at many projects for Drupal 7 and Drupal 8 and only a few Drupal 7 modules looked like they could have helped. None of what I have read for Drupal 8 appears to offer code search.

The documentation I have read, and the module I found are the following.

  • 2
    Out of interest: what CMS or other website building admin have you ever used that allows users to search for content by CSS classes? Certainly none of the major ones do, and in many years of web development it's not a requirement I've heard of before. Presumably if you're baffled by the absence of this feature it's one you're accustomed to having, so I'm interested to know what solution offers it?
    – Clive
    May 26, 2017 at 15:04
  • @Clive - wordpress' default admin content search is strictly pattern matching on titles and content. If you have <span class="whatami"></span> in body of post or page searching on span or whatami will locate the content. May 26, 2017 at 17:14
  • A more obvious search might be an admin looking for instances where fred-smith-2016.jpg or our-brochure.pdf are referenced by links in content code. Definitely comes up. May 26, 2017 at 17:16
  • 1
    Oh I see. If you're looking for something that low-tech then install Admin Views, edit the View for the content page, and add the body field as an exposed filter using the LIKE operator. That will get you pretty much the same effect
    – Clive
    May 26, 2017 at 17:49
  • 1
    Oh yeah, didn't see the "8" tag :) Glad you got a solution, I added an answer with the simple method and a potentially better method
    – Clive
    May 26, 2017 at 19:02

2 Answers 2


For a quick solution, you can edit the View that powers the Content page (or create a new View, edit a different View, etc), and add the body field as an exposed filter. Combined with a LIKE operator that should give you reasonably good results (though it will possibly depend on what input format you're using).

If you want something more like what you described, i.e. something that searches multiple fields at once, you could install the Search API module, create a results View, and add a combined filter that will search across all the desired fields. This approach takes a bit more effort, but might give more accurate results than the first one, especially if you use (for example) Solr as the backend.

  • 1
    great recommendation Clive, although in my experience LIKE will not scale for say 6+ digits of Node content, with long content bodies. So the recommendation works best for small-scale drupal sites. There will come a point where a proper FTS service is needed for the site for such searches.
    – tenken
    May 26, 2017 at 20:36
  • Agreed @tenken, common sense should be sprinkled liberally
    – Clive
    May 26, 2017 at 21:36

What you're requesting is raw content based searching. Not (necessarily) the final markup sent to the user but the content stored in the database and the ability to search the raw HTML and markup of the items' content.

You are correct that Drupal Core has no built-in functionality for this. This is largely because Drupal development is catered to editorial users, or endusers with little or no technical knowledge of the underlying structure of a website -- such as HTML and CSS.

You've listed a good supply of D7 Modules that try to solve this task, should your site need it. Look to that module list issue queues to see if any have any Drupal 8 port in-progress.

Additionally these modules support content based searching:

As an example of an in-progress Drupal 8 port from the issue queues:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.