I can’t work out why Apple’s applications don’t utilise Spotlights ability when it comes to searching for items within them. Take this as an example. If I search for Saft inside Mail, so that I can find my registration details, it returns nothing.

Saft Mail search

If I then do exactly the same search via Spotlight, it shows four results under the email messages.

Saft Spotlight search

I’m just wondering why one of Apples own applications would have such a discrepancy when it comes to searching?


I’ve been working on a 404 error page for the theme that I use here, Subtle.

I wanted to add error page support to the theme so I could utilise the error tracker plugin for Mint and also get search engines to adjust their listings for the website.

I wrote a funky bit of PHP code, which was inspired by A List Aparts: The Perfect 404 post.
What it does is look for a referral from a listed search engine and then get the keywords used in the search. It then assigns those keywords to the variable $new_search . That variable can then be used to populate your own search form.

< ?php
// Here we do some intelligent search engine 404 checking
// This allows us to show some links to possible relevant content
 
if(strlen($_SERVER['HTTP_REFERER']) > 0) {
 
    // We have a referer value somewhere
    // Look for a search engine query
    $engines = array('google.co', 'looksmart.co', 'altavista.co', 'msn.co', 'yahoo.co');
    for($I = 0; $I < count($engines); $I++) {
        $found = strstr($_SERVER['HTTP_REFERER'], $engines[$I]);
    }
    if(strlen($found) > 0) {
 
        // We have a search engine..
        // Split the referal up to get query used
        $query = explode('?', $found);
        $parts = explode('&', $query[1]);
        $part_count = count($parts);
 
        // Find specific search terms based on differing search engines
        $style = array('q=', 'p=', 'ask=', 'key=');
        $style_count = count($style);
 
        // start by looping through the URL parts
        for($s = 0; $s < $part_count; $s++) {
 
            // Match url parts against search query types
            for($t = 0; $t < $style_count; $t++) {
                $terms = strstr($parts[$s], $style[$t]);
                if($terms == true) {
 
                    // finish loop as we've found what we need
                    $s += $part_count;
                    $t += $style_count;
                    $terms = explode('=', $terms);
                }
            }
        }
        // Search terms to echo in the search box
        $new_search = str_replace('+', ' ', $terms[1]);
    }
}
?>

I’m sure the code could be tidied up a bit, but it does its job. Feel free to use it for your purposes!

lotsa emails this way!