last day (15 days later) » 

3:06 PM
0
A: Exclude taxonomy terms from search_excerpt in snippet

Mohammed ShameemThe search result is a node view and hence the hook_node_view_alter works for it. So you would could create a custom module and write the following function function custom_node_view_alter(&$build, $type) { if (($build['#view_mode'] == 'search_result') && ($type = 'node')) {...

 
Thanks you for you fast answer. I totally forgot to mention that I'm using Drupal 6 and it seems that hook_node_view_alter comes with the 7.x version.
 
in drupal 6 it is hook_nodeapi and the $op would be view
 
In fact there is an $op for search_result like in node view alter: source
 
In 6 when it comes to the "search result" the taxonomy is already added to the body. so if you are OK with hacking the code then in the node.module near line number 1307 you have the code that add the taxonomy to the snippet you can comment that out if you want. :-)
 
It does not affect search results ($op = search result OR $op = view). I'm thinking of using apachesolr_search_snippets but I can't find good information on it. On hook_nodeapi neither… Please could you give me a hint?
Yes, yesterday, hacking the code is what I did in the first place commenting "Fetch terms for snippet". But after flushing caches, nothing changed. Do I need to re-save all nodes?
 
3:06 PM
I have updated with the drupal 6 code let me know if that works for you
 
oups I tried to put your function in my theme, I need to create custom module… I tell you soon. Thanks for all you time, btw.
No, it doesn't work, but maybe it's the naming in my customresults module: I called the function-> function customresults_nodeapi and I add $node->body .= 'blah'; before the break; but nothing happens. Maybe Apache Solr module uses hook_nodeapi function and overrides the behaviour of my module.
 
could you post the complete code
 
looks fine to me. remove the $node->body .= 'blah'; and you also dont need the drupal_set_message("<pre>" . print_r($op,true) . "</pre>"); Have you cleared the cache?
 
Yes, it looks fine to me too. All caches cleared… but results not altered. Is there a way to know, if the function is called, with devel of a console log?
 
3:06 PM
when you placed the drupal_set_message("<pre>" . print_r($op,true) . "</pre>"); code did you see any result in a green box?
are you there?
 
3:18 PM
hi,
Yes the green box is loaded on all pages except on search result page.
I think apache solr is guilty !
 
could be... I need to do a bit more reaearch on that I suppose.. will try to get a solution for you :-)
you are using the apache solr module right?
and let me know the version as well
 
yes in apache solr module there is:
/**
 * Implementation of hook_nodeapi().
 */
function apachesolr_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'delete':
      _apachesolr_nodeapi_delete($node);
      break;
    case 'insert':
      // Make sure no node ends up with a timestamp that's in the future
      // by using time() rather than the node's changed or created timestamp.
      db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed) VALUES  (%d, %d, %d)", $node->nid, $node->status, time());
no case search result ; I suppose there is no conflict.
Apache Solr module version = 6.x-1.7
I modified the apache_solr hook_nodeapi like this, still same results, but I have the green box on search results page: pastebin.com/1QHPfHg5
 
3:44 PM
can you created a fucntion called customresults_apachesolr_process_results($results)
and place the drupal_set_message("<pre>" . print_r($results,true) . "</pre>"); and send me the result in the green box
 
On the solr results page, this new function returns the green box, but it is empty.
 
is there any result in the page?
did you clear cache?
 
Yes, Solr found 107 results / items.
After clearing the caches, same result, empty green box (screen capture: http://minus.com/li2S6q0yKkFuH)
 
4:00 PM
can you try to print something like drupal_set_message("testing customresults_apachesolr_process_results");
so that we are sure that the call is from that function itself
 
Yes, it prints our little message after reloading the search.
But when I move this same message from "function customresults_apachesolr_process_results" to "function customresults_nodeapi" , it's not printed anymore, after reloading the search.
 
ok
can you create a function within your template.php of your theme
 
same result, after renaming function "customresults_nodeapi" to "customresults_apachesolr_nodeapi".
 
youthemename_apachesolr_search_snippets($doc, $snippets)
and then use the drupal_set_message to print those two variables.
 
Do I keep custom module enabled?
 
4:07 PM
doesn't matter.
 
function archivescddbtheme_apachesolr_search_snippets($doc, $snippets){
	  drupal_set_message($doc);
	  drupal_set_message($snippets);
}
give a Array
Array
Array
Array
Array…
and no more text in snippet emplacement.
but maybe not the good drupal_set_message… :(
 
drupal_set_message("<pre>" . print_r($doc,true) . "</pre>");
drupal_set_message("<pre>" . print_r($snippets,true) . "</pre>");
change it to that and see
 
sorry I'm not a genius, in php and all this drupal behaviours. ok it's better nom. I make a screen capture.
 
the terms appear in the Array [0].
 
4:20 PM
is array[0] completely term or is that mixed with the body?
 
hm… you're right, it is mixed.
 
could you tell me which is term and which one is part of the body
 
Are array[0][1] the linear parts of the snippet?
the family names. For the first Array, it is "Bénédicte Vigner, Marguerite Duras " > taxonomy terms.
"10 ANS
Lorient, le 4 juillet 2005 · BÉNÉDICTE VIGNER
J'ai 17 ans quand je lis LES PETITS" is the body.
 
and second array?
I ean array[1]?
can you do one think can you send me the source of the html out put. basicaly the one in green box
 
It's hard to tell, it's not the same thing for each node. It can be another part of the body, a cck field (for example book author), or even taxonomy terms again.
Yes, I can send you the source. Which way do you prefer?
 
4:29 PM
is it possible to upload here?
or may be paste bin
 
upload here?
no, send you a link
withe html file.
greenbox is now bluebox
 
I dont see a general pattern there :-)
:-(
 
no, but I thinks the array displays only the different cuts for the snippets. It is independant of the node structure. Because my nodes are structured, and well.
There is no pattern. But the terms are already here. Which function could run before?
Sorry bad english…
 
it is coming from this function apachesolr_process_response line 390 of apache_search.module
 

last day (15 days later) »