In my teaser template, I would want to write a code for showing just the first pic.
How can I write that.

Please help.

Comments

eclipsegc’s picture

The api in the 2.x release has changed a little (function names will be slightly different but I think you can probably make sense of it).

This post outlines how to do that sort of work pretty in-depth. Hope it helps.

http://drupal.org/node/239251#comment-855545

The other option is (since you're using 2.x) you could have an imagefield for lead images and an imagefield for all other images and put two galleries on that content type. That's what I'd suggest, but if you want to do it programmatically, that link describes it fairly well.

Eclipse

michaux’s picture

Hi !
I just tried your solution.

2 imagefields : - field_vos_images (principal image)
- field_galerie_images (Gallery of image)

Teaser template :
print $node->field_vos_images[0]['view']

Body template :
print $node->field_galerie_images[0]['view']

Nothing work.
My view as the both galleries and the node as the same result.

screen result :
http://www.matinsdunet.fr/?q=view/listeaccessoire

Maybe I'm wrong ????
What do you think ?

eclipsegc’s picture

OK, let's backup a bit here.

1.) Get rid of your node-type.tpl.php that you're playing with. It is unnecessary.

2.) Under content management -> content types: edit the content type in question, then click the display fields tab up top. There you can specify what should appear in teasers and what shouldn't. Use "default" as the selection, anything else will override imagefield_gallery. Here you can set the display "hidden" for the teaser if you don't want one of your imagefields to show up there.

3.) Finally, set up your galleries and then cck and imagefield_gallery will do all the important work for you.

michaux’s picture

Status: Active » Closed (fixed)

Oh ! you are so cool, you found it.
I make all my website without that.
I never seen it.

Thanks,
Jérôme