Forums / General / using mac's spotlight for .tpl and .php

using mac's spotlight for .tpl and .php

Author Message

*- pike

Sunday 21 October 2007 4:52:12 am

Hi

I had to do much textchanges throughout a ezp site. I was using BBEdit's "find in files", but it took ages for each string. So I wanted to use Mac's "spotlight" - which does content indexing. Alas, it didn't index php and tpl files. Now it does, and here's what I did:

I read these:
http://www.macosxhints.com/article.php?story=20050514182520714
http://www.macosxhints.com/article.php?story=2005052015041510
And set to work.

For PHP first.

check if php is a recognized extension. open a terminal and type

mdimport -n -d1 myfile.php

where myfile.php actually exists. This returns something like

Import 'myfile.php' type 'public.php-script' no mdimporter

This says two things:
- the extension "php" is mapped to "public.php-script"
- there is nothing indexing "public.php-script"

To fix the second thing, let's add public.php-script to

/System/Library/Spotlight/RichText.mdimporter

if you've installed Apples Developer Tools, you'd better add it to

/Library/Spotlight/SourceCode.mdimporter

Find that file, rightclick, "show package contents". Open "info.plist",
and to the LSItemContentTypes, add one entry for "public.php-script".
Save it. In the terminal, type

mdimport -r /System/Library/Spotlight/RichText.mdimporter

which will return with

Asking the server to index files of type: ....

Now perform a spotlight search for "print" and watch php files roll in.

---

Now for tpl. Check if tpl is a recognized extension. open a terminal and type

 mdimport -n -d1 myfile.tpl

where myfile. tpl actually exists. This returns something like

Import 'myfile. tpl' type 'dyn.456fhj8679fhgjhdf' no mdimporter

This says two things:
- the extension "tpl" is mapped to "dyn.456fhj8679fhgjhdf"
- there is nothing indexing "dyn.456fhj8679fhgjhdf"

To fix the first thing, we have to add a UTI for extension ".tpl"
To do this, I downloaded http://www.lexa.ru/andyt/MyUTIs.bundle.zip,
unzipped it, rightclicked, "show package contents". Open "info.plist",
and added one entry for extension ".tpl", mapping it to "no.ez.template".

Then, I put the bundle in my Applications folder and rebooted.
After rebooting, I opened a terminal and typed

mdimport -n -d1 myfile.tpl

This returns something like

Import 'myfile. tpl' type 'no.ez.template' no mdimporter

This says two things:
- the extension "tpl" is now mapped to "no.ez.template"
- there is nothing indexing "no.ez.template" yet

As with the php example, I edited

/System/Library/Spotlight/RichText.mdimporter

I opened "info.plist", and to the LSItemContentTypes, added one entry for "no.ez.template". Then I went to the terminal and typed

mdimport -r /System/Library/Spotlight/RichText.mdimporter

And in spotlight, I did a search for

i18n(-php)

.. and waited for the templates to roll in ..

wow :-)
*-pike

---------------
The class eZContentObjectTreeNode does.

Ole Morten Halvorsen

Monday 22 October 2007 2:44:08 am

Cool! Thanks for the tip. Spotlight is supposedly faster in Leopard so this will be even more useful in the a week or so :)

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578