Hello,

I've been trying to figure out how to call a page's taxonomy image from another page (I'm using movie_db module to create a database and want it to include thumbnail images on the cast and crew pages, much like imdb).

This is the code where I'm trying to place the picture:

 if($node->actors[0]) {
$actors = theme_mdb_movie_people($node->actors);
$output .= "<br>";
$output .= "<b><u>";
$output .= "Cast";
$output .= "</b></u>";
$output .= " <TR><TD>";
I WANT THE PICTURE HERE
$output .= "</TD><TD> <div class=\"label2\">". t('') ." </div><div class=\"content2\">". $actors ."</div> </TD>\n";
if($node->characters) {
$output .= " <TD><div class=\"label2\">". t('.....') ." </div></TD> <TD> <div class=\"content2\">". $node->characters ."</div> </TD>\n";
}
$output .= "</TR>";
}

No matter what I do (I am still learning php and Drupal as and when I can), I just can't seem to call the image from the page being refered - in this case $node->actors[0]['nid'].

Any help that you could give me would be so greatfully receieved - or even pointers in the direction - everything I try just seems to end up in an error or just a blank bit.

Many thanks,

Ian

Comments

nancydru’s picture

Status: Active » Postponed (maintainer needs more info)

Something on the order of:

      foreach ($node->taxonomy as $term) {
        $output .= taxonomy_image_display($term->tid);
      }

Oh, I reread the note and see that this is probably not what you want - it shows the taxonomy image for the node you're on.

So, you actually want the image associated with $node->actors[0]['nid']? Let's see...

  $actor_tid = db_result(db_query('SELECT tid from {term-node} WHERE nid=%d', $node->actors[0]['nid']));
  $output .= taxonomy_image_display($actor_tid);

You probably could combine that all into one statement, but it's a bit more readable this way.

ultimatedruid’s picture

Thanks for the message, however the following error comes up:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-node WHERE nid=0' at line 1 query: SELECT tid from term-node WHERE nid=0 in /home/ltdbco/public_html/testing/includes/database.mysql.inc on line 172.

I've tried a few things, but still can't get it to work - any ideas?

Many thanks,

Ian

nancydru’s picture

That's telling me that "$node->actors[0]['nid']" is not right - it is zero or non-existent. When you find the correct way to reference the node, then you put that into the query.

ultimatedruid’s picture

Using

$actor_tid = db_result(db_query('SELECT tid from {term-node} WHERE nid=%d', $node->actors[0]));
$output .= taxonomy_image_display($actor_tid);

It brings out the following error - slightly different:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-node WHERE nid=1' at line 1 query: SELECT tid from term-node WHERE nid=1 in /home/ltdbco/public_html/testing/includes/database.mysql.inc on line 172.

I've had a look but I don;t really understand - the nid= value always reads 1, when it should read different values...?

Sorry for my lack of knowledge!!! I just feel so close, but yet so far!!

nancydru’s picture

Yes, the nid value should change for each actor.

nancydru’s picture

Yes, you were close. I downloaded the module and found out it is "$node->actors[xx]->nid" where "xx" is the counter for each actor.

BTW, I'm not sure that Image Attach (part of Image) wouldn't be better for this application.

ultimatedruid’s picture

Hello,

Thank you so much!!! It works - however, I did have to change the {term-node} into {term_node}. Thank you so much for your help!!!

I've been trying to get the same sort of assistance with other image modules, and spent hours on each one, but yours is the first that has worked (ultimately thanks to your assistance - that no one else would give). So thank you very much!!! It truely is mosules like this that make drupal so good!!!

Best wishes,

Ian

nancydru’s picture

Status: Postponed (maintainer needs more info) » Fixed

Not to toot my own horn, but you will probably get more attention from me than almost anyone else. I try to maintain my modules the way I want others to maintain theirs. I have taken on co-maintenance on several that weren't getting attention and that I wanted updated.

I'm glad it's working for you. I'd like to see the finished product when it's ready.

nancydru’s picture

Status: Fixed » Closed (fixed)