Closed (fixed)
Project:
Search Lucene MoreLikeThis
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
8 Sep 2009 at 14:32 UTC
Updated:
2 Oct 2009 at 21:10 UTC
Hi Chris,
The theme function theme_luceneapi_morelikethis_block($items) does not expose the node nid. The $items array contains the node title and node path (alias, not drupal), but not the node nid. Therefore, to attain the node->nid, one would have to query the db which seems really unecessary, seeing as the function _luceneapi_morelikethis_block_view that calls the theming function has all the needed information, but simply does not pass it along.
Can this be added?
best wishes
scotjam
Comments
Comment #1
cpliakas commentedThis is a feature that most definitely should be added. Look for it in the next alpha release.
Thanks,
Chris
Comment #2
cpliakas commentedHi scotjam,
After having some time to read through my own code and think about this a little more, you can actually just call the luceneapi_morelikethis_nid_get() function to obtain the node ID. It statically caches the node ID that it calculates, so only one query is executed no matter how many times you call it. I think that it makes the most sense to make use this function as opposed to passing a node ID to the theme function, but I am willing to discuss. My thinking is that there might be cases in the future when non-node text is used as the source when calculating a moreLikeThis query, so a node ID might not always be available.
Either way, thanks for pointing out this use case and making me think more about it,
Chris
Comment #3
cpliakas commentedPlease disregard the last post, as I misunderstood what you meant. The item (in this case the node), should most definitely be available for the matched items. Obviously I was thinking about the node being used as the source text. Changing back to a task to make this information available.
Comment #4
cpliakas commentedA solution has been committed at #264652. The entire hit object is attached to each item in $itmes, so you will be able to get the node ID. Code example is below: