function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mattclausenmattclausen 

Adding Search to Site.com Site

I am using Site.com to build a public site that displays content from a custom object. I would like to add a search box to the site.com page that would allow users to perform a text search against the data in the custom object. How would I do this?
Sonam_SFDCSonam_SFDC
Since searching Site.com static content is not provided out of the box, one way to achieve this is to create a widget based on using Google site search : http://www.widgetbox.com/widget/google-sitesearch
bryan.anderson.M360bryan.anderson.M360
I was just going to check out WidgetBox, but they actually shut down on March 28.
Tyler SchryverTyler Schryver
I've done this with a custom object. You need to include a custom controller for your visualforce page that has the search field in it. Here's the controller.
public with sharing class empsearchcontroller {  public list <employee_directory__c> emp {get;set;}  public string searchstring {get;set;}  public empsearchcontroller(ApexPages.StandardController controller) {   }     public void search(){  string searchquery='select name,id from employee_directory__c where name like \'%'+searchstring+'%\' or department__c like \'%'+searchstring+'%\' Limit 100';  emp = Database.query(searchquery);     }     public void clear(){     emp.clear();    }   }

Here's the visualforce page: 
<apex:page standardController="Employee_Directory__c" extensions="empsearchcontroller">  
  <apex:form >  
 <apex:inputText value="{!searchstring}" label="Name:"/>   
  <apex:commandButton value="Search records" action="{!search}"/>  
  <apex:pageBlock title="Search Result" >  
       <apex:outputText value="Input a first name (or part thereof) or last name (or part thereof) or department in the box above and press 'Search' "/>
       <apex:outputText value=" Search results will appear below. Click on a name to view that record."/>
    <apex:pageblockTable value="{!emp }" var="a">  
     <apex:column >  
      <apex:outputlink value="/{!a.id}"> {!a.Name} </apex:outputlink>  
     </apex:column>  
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
  </apex:form>  
 </apex:page>

Then you'll need a second visualforce page that displays the data that is selected. In order for a public site.com to use it, it must be used in the 'view' button. 

User-added image