How to get Apache Solr URL in Drupal 7 themes/ modules/ templates

By

December 31, 2012Code DrupalNo comments

Apache Solr Search Integration is a drupal module that provides Search API that can be used as a replacement for core content search and boasts both extra features and better performance. This module integrate Apache Solr Search Platform and Drupal.
.
In order to check Whether Apache Solr  is down in your server you need to access the Solr URL in multiple pages of your drupal site. By default from your apachesolr D7 module there is no separate function to get the Solr URL. However the below function will return the Solr url configured in your server from D7 admin end.

Through this function you can access the URL in any page template, theme, modules … etc

  • When you install apachesolr module in D7 it will extract files under module directory,
  • Navigate to <YOUR_MODULE_DIRECTORY>/apachesolr/
  • You will be able to see apachesolr_search.module file, open the file
  • Copy / Paste the below function at EOF and save it.

Using the above function you can access the Apache Solr URL anywhere in your Drupal site. You can access the URL like as shown below,

Leave a Reply