Question

I'm working with Drupal at the moment and I'm having a real hard time searching the contents of various .module files. For example I want to search for something like "div style="border: 1px solid red;" and find out which file it's in.

All my code editors ignore the .module files in their search because it is a strange extension. Windows won't do it because it's on a networked location.

Any ideas?

Was it helpful?

Solution

Install Cygwin, open a shell in your Drupal site's directory, and use grep --- a commandline utility to search files using regular expressions.

Something like this:

grep -r 'div style="border: 1px solid red;"' *

would recursively search every file for that string.

Or:

find . -name '*.module' -exec grep -H 'div style="border: 1px solid red;"' {} \;

would search only the .module files.

OTHER TIPS

ack can do that for you pretty happily. For more convenience, you can also add in your .ackrc file the following: --type-set=drupal=.php,.inc,.module,.install,.info,.engine --type=drupal

So that typing

$ ack string

will find string in all drupal files under the current directory.

(Yes, it runs on windows, see the link).

What I do:

Use firebug, it will tell you the exact file and then you can browse the system for that style. You'll want to turn off CSS caching for this temporarily.

Generally, there aren't too many (or shouldn't be any) CSS rules being defined in the .module files anyway.

If all else fails, you can use something like Agent Ransack or, for a more command line unixy feel, the king of command line search: grep.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top