BigJobbies
BigJobbies

Reputation: 4343

Drupal 7 - Splitting up the content

Im very new to Drupal so im hoping this is an easy one.

I have been given a template to cut up and import into Drupal 7.

I want the user to add as many images as they want for each specific page so i have enabled unlimited image fields on the 'manage display' in the 'Basic Page' content type.

So far this is perfect, it allows them to choose a bunch of images that they want attached to the page.

The part im having problems with, is that when i view the page, its showing along with the body content.

The template i have, puts the images at the very top of the HTML and the body content at the bottom of the HTML.

Im using

<?php print render($page['content']); ?>

in my page.tpl.php file.

Is there any way to drill down further so it will only display the 'body' in one part of the template, and then a loop to display the images on another part of hte template?

Any help would be great, i have been battling this for hours now.

Cheers,

Upvotes: 2

Views: 4610

Answers (2)

Rick
Rick

Reputation: 11

Yes D7 makes this easy:

<?php print render($content['body']); ?>

and for any field:

<?php print render($content['field_my_field_name']); ?>

note you do this in node.tpl.php not page.tpl.php

Upvotes: 1

Avey
Avey

Reputation: 68

I primarily work with Drupal 6 and haven't personally tested Contemplate in Drupal 7, but hopefully I can give you some ideas for where to start.

The images are part of the node's content and of course as you've found out you don't get any control when just printing $page['content'] in the theme. The tough thing about drilling down is figuring out the correct names of everything, so the solution we've always used for your problem in Drupal 6 is the Contemplate module.

Contemplate is "Content Template" and helps you out with this issue by giving you the names of the fields you are after and an example node with the data, so you can skim through it and get an idea how to pick and choose the correct names. It then allows you to save your template and will use it when rendering node content.

It looks like Contemplate is available in Drupal 7 now, the current version is 7.x-1.0-alpha2. Contemplate has worked wonderful for us in Drupal 6, so it's probably worth a try in Drupal 7.

Upvotes: 2

Related Questions