Note: this only works on Nitallica.Org and not on any sites mirroring this feed. ;)
(Posted to WordPress support earlier today … this version modified for content and because I wanted to ;))
A while back I had installed Search Meter on several of my blogs — mainly to see what my visitors were looking for. This has come in very handy on Now We’re Cookin’! — if I see searches for a dish I don’t have, I hit my cookbooks or the net until I find something. :)
I check my Search Meter results just about every day to see what my visitors look for most. Here on my domain, I see a lot of searches by what are probably spam bots, for porn related crap. However, I also happen to know of several friends who regularly come on and search for certain keywords looking for dirty jokes. (Hey, you know me and my wild hairs ;))
I decided to customize my search page a bit to show a custom message at the top of the search results or “not found” message for certain topics — and maybe have a little fun with my visitors. ;)
At the top of my index.php I added the following:
<?php
$searchval = "";
if(isset($_GET["s"]))
$searchval = $_GET["s"];
elseif(isset($_POST["s"]))
$searchval = $_POST["s"];$crack = eregi("(PATTERN)",$searchval);
$pron = eregi("(PATTERN)",$searchval);
// Replace PATTERN with a string of related words separated by pipes.
$l2s = eregi("(learn to search|information station)",$searchval);$crackmsg = "<h2>*** Notice ***</h2><p><strong>It appears that you are looking for illegal subject matter. ";
$crackmsg .= "Sorry, I got out of that gig a <em>LONG</em> time ago. ";
$crackmsg .= "Nothing of that kind can be found on this website. My advice to you: ";
$crackmsg .= "Try Google Blog search or Astalavista.</strong></p>";$pronmsg = "<h2>*** Notice ***</h2><p><strong>It appears that you are looking for adult subject matter. ";
$pronmsg .= "This kind of material is not present on this site. ";
$pronmsg .= "You are probably a spam bot – your IP and complete header information have been logged.</strong></p>";$l2smsg = "<h2>*** Notice ***</h2><p><strong>It appears that you are looking for my old Learn to Search website.";
$l2smsg .= "It was taken down prior to my retirement and will not be reappearing. ";
$l2smsg .= "If you are in need of tutorials for searching/scouring the net, I highly suggest ";
$l2smsg .= "<a href=\"http://www.searchlores.org/\">SearchLores</a>.</strong></p>";$continuemsg = "<p> </p><p><em>If you are not, my apologies ";
$continuemsg .= "… continue on with your search … </em></p><p> </p><hr /><p> </p>";?>
About halfway down the file (depending on how your template is setup), under the elseif( is_search() bit, I add:
<?php
if ($crack) {
echo "$crackmsg";
echo "$continuemsg";
} elseif ($pron) {
echo "$pronmsg";
echo "$continuemsg";
} elseif ($l2s) {
echo "$l2smsg";
echo "$continuemsg";
}
?>
I added the continuemsg just in case it’s a valid search … I don’t want to embarrass them too much. ;)
And on down where the “Not Found” message is, I replaced that couple of lines with:
<?php
if ($crack) {
echo "$crackmsg";
} elseif ($pron) {
echo "$pronmsg";
} elseif ($l2s) {
echo "$l2smsg";
} else {
echo "<h2>Not Found</h2><p>Sorry, but you are looking for something that isn’t here.</p>";
}
?>
This can easily be modified to handle any topic … I just wanted to share in case anyone else had wanted to do this, or hadn’t thought to. *grin*
The Socials
Webrings!
<< · The Geek Ring · ?? · >>
<< · The HotLine WebRing · >>
<< · The Retronaut Webring · >>
<< · Ladies of the Links · ?? · >>
<< · Free Speech WebRing · >>
<< · Silly.City WebRing · ?? · >>
<< · The Cuddler Webring · >>
<< · NetRing Nerds · ?? · >>
<< · devring.club · ?? · >>
<< · Bucket Webring! · >>