Closed (fixed)
Project:
Apache Solr Search
Version:
6.x-2.0-beta2
Component:
More Like This
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 May 2010 at 15:37 UTC
Updated:
26 Jun 2012 at 15:00 UTC
It would be awesome to be able to show images in this block. I am working on a project for a large e-commerce site with Apache SOLR powering the product browsing. The more like this works really well, but the client really wants to show images in the block. I have been trying to get my imagefields indexed in SOLR with some limited success (see #627448: Display Images in Results).
Any help would be appreciated!
Sean
Comments
Comment #1
jpmckinney commentedCan't you just write a custom implementation of the theme function: theme_apachesolr_mlt_recommendation_block?
Comment #2
pyrello commentedHaha... yeah. That is what I was trying to do. I spent a lot of time trying to figure out what all was stored in the $result variable, but a lot of it is serialized information. When I tried to unserialize it, it didn't seem to work.
I'll try to recreate the code I was working up. Maybe I was doing something obviously wrong and a second set of eyes could spot it.
Thanks for the response,
Sean
Comment #3
jpmckinney commentedHere is the default implementation of the theme function:
http://drupalcontrib.org/api/function/theme_apachesolr_mlt_recommendatio...
Comment #4
pyrello commentedSo, using this:
and presuming that I have a field getting indexed as $document->ss_image_path, how would I add the image?
Sean
Comment #5
jpmckinney commentedTry:
Not sure what your ss_image_path values looks like.
Comment #6
pyrello commentedHello,
I really appreciate all of your help and patience. I implemented your code and am not getting it to work, but I am pretty sure it is because of #627448: Display Images in Results not working either. I have written a detailed post in that issue queue, since I believe it is the source of the issue and once I get that to work, I will have this working as well.
Sean
Comment #7
pyrello commentedI have since gotten this to work by implementing the final missing bit of code over at #627448: Display Images in Results which actually loads the indexed field into the $document object for output into search results, I think. Either way, it is working.
Thanks for all of your help, I really appreciate it. I plan on eventually releasing the custom code that was generated as an add-on module to make the integration between apache solr and ubercart much smoother.
Sean
Comment #8
pyrello commentedAnd updating status...
Comment #10
guruslot commentedAnyone did successful implementation of imagecache images into MLT block?
Thanks
Comment #11
pyrello commented@Guruslot - here is the snippet that we are using to override the output via
template.phpin our custom theme:The relevant part is that we are using node_load() and node_view() to output these as teasers. The rest of it is just styling it to work with the grid we are using for our custom theme.
Comment #12
guruslot commentedThank you very much, Pyrello.
Your snippet really works. But it outputs a complete node teasers. My goal is to have a small MLT's block with thumbnails (using imagecache) and node titles.
And I tried to use a snippet #4. It works. But it outputs only titles. I'd like add only thumbnails to it.
So, I did the following code:
It works, but there is one issue - it separates as list with
<li> </li>thumbnails and titles. The first $links[] statement does not print title...Could you advice on it, please?
Comment #13
pyrello commented@Guruslot - this is because you are adding to the $links array 2 times every time the foreach loop cycles:
When you theme the $links array using
'list_item', it takes each item in the links array and turns that into an<li></li>element. I haven't tested it, but I think the following code should work:Comment #14
guruslot commentedIt works, confirm! Thank you so much, Pyrello!
Comment #15
nick_vhComment #16
nick_vhComment #17
brephraim commentedThis doesn't work for me; I assume this is because the code is written for 6.x whereas I am running 7.x.
Does anybody have a successful implementation for 7.x?
Comment #18
pyrello commented@brephraim - You are correct that it doesn't work because the code has changed for 7.x. But the approach is still the same. You'll need to override the same theme function in your template.php file. The 7.x version of this theme function is:
I would start with that in your theme. I am not as familiar with how the render functions work and how they are different from the theme functions that were used before (ex.
theme('item_list', $links)), so I am not sure exactly how to update it, but that is the route I would take.