Thanks for the great module. I have a client who would like to implement node_compare with a views page of a search_api index. Possible? The client would likely be willing to pay for this feature. Anyone want to take this on?
Thanks for the great module. I have a client who would like to implement node_compare with a views page of a search_api index. Possible? The client would likely be willing to pay for this feature. Anyone want to take this on?
Comments
Comment #1
robit8deb commentedI second this. My view returns indexed nodes and the add to compare is not available as field on the view. Comparing search results side by side would be great.
Comment #2
robit8deb commentedIf anyone is trying to integrate with a search result view the quick way is to add a custom text field and add this:
<a id="compare-toggle-[nid]" class="compare-toggle use-ajax add" href="compare/toggle/[nid]/nojs?destination=<view page url>" rel="nofollow">Add to compare</a>Make sure you have the nid field added and hidden before the custom text field so you can use the [nid] token.
Comment #3
deardagny commentedI did what robit8deb did, and while it works to an extent, the link doesn't behave correctly when navigating back and forth from a Search API results page. If you add a node to compare, navigate to the actual comparison page, then come back to the results page, the "Remove from compare" button doesn't appear on that node (because the view is just printing a static field).
I would think just adding the dynamic "add to" link to a views field tpl would work. The field itself shouldn't be indexed anyway.
Comment #4
michel.g commentedI made it work locally defining a new handler in which I overwrite the add_additional_fields function and retrieve my field info differently:
Then you create a MODULE_NAME.views.inc file in which you set your data similar to node_compare_views_data_alter, just instead of $data['node], you will change your search_api_index table value. (In my case 'search_api_index_default_node_index')
I didn't want to create a patch because then you need a dependency on the entity module...
Comment #5
michel.g commented