Hi,

i am writing a tutorial for theming the autocomplete output for both finder 1.x and 2.x.

So i did a clean install to make sure i get everything right. As a matter of fact, i can´t use node_load($option->nid); in the theme_finder_autocomplete_suggestion. This is very strange, $option->field_name is there. I tried to dsm() $option without luck.

Anyone with the same problem ?

Comments

danielb’s picture

Can you double check which version you have installed?

john_the_noob’s picture

Hi,

it´s Drupal 6.22 and Finder 6.x-1.17.
http://www.johnstestserver.de/d6f1/finder/cool_finder/

The ouput is 4 lines:

function theme_finder_autocomplete_suggestion($option, $finder_element) {
  
   //load the node object !
$node = node_load($option->nid);    
   //start a div container
  $output  = '<div>';
   // the title
  $output .= '<br>node-title:'.$node->title;
    //the nid
    $output .= '<br>node-nid:'.$node->nid;
   //the title as in option
     $output .= '<br>option field name:'.$option->field_name ;
   //the nid as in option	
  $output .= '<br>option nid:'.$option->nid.'<br>';
    //close the surrounding div
  $output .= '</div>';

  return $output;
  
  
}

If i use $node = node_load(7); i get the correct results for node/7. So there lies the problem. I tried to switch back to a working 1.10 from another installation but no luck. Very weird.

john_the_noob’s picture

Ok, i now managed to give out $option, look like:

finder_field_1 (String, 30 characters ) first test page 1 first page 1
field_name (String, 14 characters ) finder_field_1
display_field (String, 14 characters ) finder_field_1

-> Still live here: http://www.johnstestserver.de/d6f1/finder/cool_finder

danielb’s picture

Version: 6.x-1.7 » 6.x-1.17

I don't seem to have any troubles with $option->nid (or more correctly $option->{$option->base_field})

I tried to dsm() $option without luck.

Try dpm() - you should see the output after a page refresh. See my tips here; http://drupal.org/node/1342234

I get some output like this:

... (Object) stdClass

nid (String, 2 characters ) 10
node_title (String, 12 characters ) A story node
node_language (String, 2 characters ) en
finder_field_1 (String, 12 characters ) A story node
base_table (String, 4 characters ) node
base_field (String, 3 characters ) nid
set (String, 0 characters )
field_name (String, 14 characters ) finder_field_1
display_field (String, 14 characters ) finder_field_1

Krumo version 0.2a | http://krumo.sourceforge.net Called from /home/braksato/public_html/drupal6/themes/garland/template.php, line 107

If you continue to have trouble with this, post an export of your finder. Perhaps there is a bug specific to your configuration?

danielb’s picture

Status: Active » Postponed (maintainer needs more info)
danielb’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

LGLC’s picture

Version: 6.x-1.17 » 6.x-1.26
Status: Closed (fixed) » Active

Wasn't sure whether to open a new issue or not as the description would have been almost identical - apologies if I should have.

I'm trying to theme the autocomplete suggestions and have realised that $option doesn't seem to contain any nid information (for a node finder), meaning I can't do a node_load.

Here's my theme function:

function mytheme_finder_autocomplete_suggestion($option, $finder_element) {
  dpm($option);
  return $option->{$option->display_field};
}

When I refresh the page after using the autocomplete, Devel outputs the following information about option:

(Object) stdClass
finder_field_1_matched (String, 1 characters ) 1
finder_field_1 (String, 10 characters ) test title
field_name (String, 14 characters ) finder_field_1
display_field (String, 19 characters ) finder_field_1_safe
finder_field_1_safe (String, 10 characters ) test title

Any pointers on how I could grab the node and therefore the other fields would be amazing.

Thanks!

LGLC’s picture

Category: support » bug

Oops, should probably have changed it to a bug report considering the theming guide at http://drupal.org/node/1342234 no longer works.

danielb’s picture

2nd paragraph of the theming guide states 'views finder'... you said 'node finder'....

LGLC’s picture

Status: Active » Closed (works as designed)

Ah thank you very much for pointing that out, danielb! It all works perfectly with a views finder. I've updated the theming guide to make this clearer in case other people make the same mistake as me.