Projects » Silverstripe/PHP Projects » Integrating the JRank Search Engine into a Silverstripe Site » Installing and Using the JRank for Silverstripe Integration Code

Installing and Using the JRank for Silverstripe Integration Code

Installing the JRank code into a Silverstripe website is achieved via the following steps:

  • Download the JRank for Silverstripe archive,
  • Copy the contents of "mysite/code" in the archive into the "mysite/code" directory of your website,
  • Create a JRank account,
  • Enter your JRank API key into "mysite/code/SearchResultsPage.php",
  • Create a search results page template based on your website's theme(s), using the provided example template (see "mysite/templates/SearchResultsPage.ss" in the archive) as a reference,
  • Rebuild the Website's database, i.e., visit http://yoursite/dev/build/?flush=all
  • Create a search results page (at URL: "http://yoursite/search"), and
  • Modify the website templates in order to add the search box wherever it is desired; see "examples/SearchEntryBox.ss" in the archive.

The example template files ("examples/SearchEntryBox.ss", and "mysite/templates/SearchResultsPage.ss") must be customized to your website. In particular, all occurrences of "http://yoursite/" should be replaced with the base URL of the website in which it is being installed. Likewise, it is essential that your JRank API key is inserted into "mysite/code/SearchResultsPage.php", or JRank will not know which site it should return results for, and will return an error.

Once all of the steps above have been completed, the search engine should be integrated into your website. You will probably have to wait a day or so for JRank to perform initial indexing of your website. Just make sure that your "robots.txt" allows JRank's indexing bot to access your website.

NOTE: I made the SearchResultsPage class a child-class of SiteTree so that I could eliminate the left-column navigation bar for the search results, which would have made the layout too cramped. If you want to use the same base layout as the rest of your pages, change the SearchResultsPage to be a child-class of Page, the SearchResultsPage_Controller to be a child-class of Page_Controller, and move SearchResultsPage.ss to templates/Layout.





Projects » Silverstripe/PHP Projects » Integrating the JRank Search Engine into a Silverstripe Site » Installing and Using the JRank for Silverstripe Integration Code