Hi,

How can I display a field twice within a node (in Drupal 7)? There is an image field in one of my content types and I would like to display that same image both at the top and bottom of the "post". Is this possible?

Thanks in advance.

Comments

kssundar’s picture

Create a tpl file for that content type (node-content-type.tpl.php) and add code something like this:

<?php
// not sure about the exact structure - do print_r($node) to see the full structure of $node variable
  print $node->field_image[0]['view']; 
  print $content;
  print $node->field_image[0]['view'];
?>

Format the tpl according to your website template.
Note: in display filelds tab of content type, hide the image field from being displayed.

Regards,
Sundar

volongoto’s picture

Thank you for your response. I'll try this and report back.

woop_light’s picture

Thank you for the response. I see why it works perfectly well in volongoto's case; however, I am hoping that someone might be able to a similar issue - but with a wrinkle.

I am similarly trying to display the same field twice -- in my case it's a location rather than an image -- and the second time I display the location I want to display it as a GMap. I've had no trouble getting the GMap working. Ordinarily to show both the address and map I would just set the location's display setting to "Address with map", but I want the address as the second in the sort order and the map as the sixth (of seven) in the sort order in my content type.

(Important Note! I played with displaying the map as a views block, which in turn seemed inconvenient for a couple of reasons. First, it kept showing up showing up in the 'Edit' portion for a given piece of content, when I only wanted in the 'View' portion. Second it's less convenient organizationally since it's a separate block and the other content flow is managed under the 'Manage Display' page for the content type. There is a good chance I'm overlooking something here.)

Any help is much appreciated!

woop

mmtahir’s picture

I have an image field (multiple) and wanted to display the first one at the top of the article and all images (slideshow) at the bottom of article. I was expecting some way with DS but couldn't find.

mmtahir’s picture

I just found it was possible with Display Suite code field with a little tweaking into code. What I did,

  • Installed Display Suite,
  • Added code field via admin/structure/ds/fields and gave it a different name e.g. article_image_1
  • Checked Node inEntity list
  • Added the following php code into the code field
<?php if(!empty($entity->field_article_image['und'][0]['uri'])){?>
  <a rel="lightshow" href="<?php print file_create_url($entity->field_article_image['und'][0]['uri']); ?>">
    <img src="<?php print file_create_url($entity->field_article_image['und'][0]['uri']); ?>" /></a>
<?php }?>
  • Selected Display suite code from text formats and saved the field

The field was available at Manage display tab of my content type i.e. admin/structure/types/manage/[Content type]/display which I easily placed where I wanted.

dan_lennox’s picture

You can also skip out on the php code by creating 'dynamic display' field using the display suite module.

  1. Install display suite
  2. Go to admin/structure/ds/fields/manage_ctools
  3. Check node in entity list.
  4. The field should now be available at your content type's display settings page. Click 'Select content' under the display settings for the field.
  5. In the modal window, select 'node' then the field you want to display a second time.
hockey2112’s picture

@dan_lennox, thanks for this tip! It worked nicely for me. One thing to add... you must "Select A Layout" in the display for the content type in question. Once you do that, the custom field you created will show up, as will the buttons that will allow you to create more custom fields directly from that page.

DanijelSVK’s picture

@dan_lennox @hockey2112 thanks, works great...

michael_lessard_micles.biz’s picture

Not obvious : thank you !

Michael Lessard
webmaster of Quebec City "democracy in action" media