Thanks for the code Jakie.
I added a snipet to the search.php to turn on a layer that was being searched if it was off by default.
below is the code I added an else statement at the end. Seems to work ok.
try
{
$featureSrvc = $siteConnection->CreateService(MgServiceType::FeatureService);
//Create a temporary map runtime object, locate the layer
$map = new MgMap();
$map->Open($resourceService, $mapName);
$layers = $map->GetLayers();
$layer = null;
//fwrite($logHandle,"found layers:".$layers->GetCount()."\n");
for($i = 0; $i < $layers->GetCount(); $i++)
{
$layer = $layers->GetItem($i);
//fwrite($logHandle,"found layer:".$layer->GetName()."\n");
if($layer->GetName() == $layerName)
break;
}
if($layer == null)
{
trigger_error(FormatMessage("SEARCHLAYERNOTFOUND", $locale, array($layerName)));
}
else
{
$layer->SetVisible($visible);
$layer->ForceRefresh();
$map->Save($resourceService);
}