0

I have created certain pages and blocks using web services programmatically.The content of those pages is fetched from outside the existing Drupal installation and they are not getting indexed in search results.

Is it possible to index my custom page titles and links in the search results? Or is there any other way to do this?

4
  • These custom pages you mention: are they nodes?
    – AKS
    Commented May 12, 2016 at 7:04
  • not nodes, for example, I am displaying camps and events from our group website through web services programmatically with the help of hook_menu, drupal_http_request and so on. I am not creating any any nodes of those contents, just showing it. Commented May 12, 2016 at 7:31
  • Well technically you can index custom contents. Node module and user module invoke search module (not the other way around). Node module is particularly a great example.
    – AKS
    Commented May 12, 2016 at 8:12
  • How? any code example? Commented May 15, 2016 at 10:48

1 Answer 1

0

Yes of course you can. You can use the hook_node_update_index() for this:

function YOURMODULE_node_update_index($node) {
   // here is an example that fetches content from an url and appends it to
   // to the data that will be indexed
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURL_URL, "http://example.com/readme.txt");
   $content = curl_exec($ch);
   curl_close($ch);

   // return the extra content that needs to be indexed for this node
   return $content;
}

The above will of course only work if your custom pages are stored as nodes in Drupal. For instance if you have a node that is called contact which shows content generated externally, then you need to fetch the same content in hook_node_update_index() for this specific node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.