Suggestion: do not render the button when view mode is search_index

I'm building a D7 website with apachesolr and addtoany (Green square "share" button, 'Display in LINK section ' set to on)

Now IIRC, when ApacheSolr indexes nodes that do not have a teaser, it creates a text snippet by simply rendering the nodes (apachesolr.index.inc , +/- lines 25 / 35, drupal_render() ) using the first line / characters. This snippet can be used when displaying search results.

However, if I enable AddtoAny on a content type, this snippet is empty on some (not all) of the nodes of that content type, the end result being that some search results have a title + snippet while other results only yield the title. So I've looked a bit at the code and added a few drupal_set_messages for debugging, and I've noticed that sometimes the snippet sent to Solr becomes:

(Addtoany button)
(newlines)
(my content goes here)

instead of

(my content goes here)
(newlines)
(Addtoany button)

Note that this AddToAny link is always at the bottom of the page when I simply navigate to that node, so I assume there is some javascript involved on creating/displaying the link.

It seems to work ok when I add this one-liner in addtoany.module (line 34)

if ($view_mode == 'search_index') return;

as the first line of the function addtoany_node_view($node, $view_mode)
(and re-indexing the site of course)

Comments

BartHanssens’s picture

(of course, it can be a general apachesolr issue instead of an addtoany)

micropat’s picture

Status: Active » Closed (fixed)

Should be fixed by now (possibly here: #1079696: Views Integration in teaser mode.). Feel free to re-open if this is still an issue.