I'm using this module with views. Each row returned a score of NULL. Might be a duplicate of #1796520: No score for any content and #1927778: The module does not work on the Russian-language sites. My investigation has shown it was because of the body field. Similar entries uses code like $node->body[$node->language][0]['value'] to access the body content. But obviously, the body field doesn't necessarily have to be of same language as the node. For example, $node->language is 'de', while the content field in my case is $node->body['und'][0]['value']. I'm not sure about the basics of this, but my solution for this scenario was, to replace the loop in the query builder routine like below: /** * Builds the query. */ public function query($group_by = FALSE) { $boolean = !empty($this->options['boolean_mode']); $text = ''; // Since the view could have multiple nid arguments, load each node // and populate the $text variable with node titles and bodies. foreach ($this->value as $nid) { $node = node_load($nid); if (isset($node->title)) { // Remove punctuation from the title. $title = preg_replace('/[^a-z0-9 _-]+/i', '', $node->title); // Alter the relevancy of words in the node title if option is selected. if ($boolean && !empty($this->options['source_relevance']) && isset($this->options['title_operator'])) { $title = $this->alter_node_title($title); } $text .= " $title"; } // watchdog('DEBUG', 'lang=' . $node->language, array(), WATCHDOG_DEBUG); if (isset($node->body)) { if (isset($node->body[$node->language])) { $bodyContent = $node->body[$node->language][0]['value']; }else{ $bodyContent = $node->body['und'][0]['value']; } } if (!empty($bodyContent)) { // Strip tags and add slashes only to the body before adding the title. $body = trim(addslashes(strip_tags($bodyContent))); $text .= " $body"; } } (file is: similar/views/similar_handler_argument_nid.inc) Hope it helps somebody!

CommentFileSizeAuthor
#1 similar_entries-i18n-1958136.patch1.6 KBvkapas
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vkapas’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.6 KB

Thanks, Shnapoo! Working for me (Russian language site) with last Similar 7.x-2.0-beta5.

In attach — ready patch-file.
Please review the code and move to core.

jenlampton’s picture

Status: Needs review » Needs work

Thanks for working on this @vkapas and @Shnapoo, it looks like this solution is pretty close! All it needs is a little reformatting to adhere to Drupal coding standards and it should be ready for merging.