Hi,

Actually i have created a new content type with image using CCK. That content type contain some fields which are shows line by line in that corresponding page. But in the node.tpl.php the full content stores in $content . So i need to split the fields inorder to redesign that. Can any help for that ?

Thanks
Regards
S.Sundhar

Comments

ore’s picture

dont use $content in node.tpl.php

just pull out the individual theme fields as you need them.

remove $content replace with debug output. var_dump($node); and look at all the fields you wish to output.

for instance a custom field you seen in your ouptput such as address would be output like this:

<div class="field field-type-text field-field-address">
  <h4 class="field-label">address</h4>
  <div class="field-items">
    <?php foreach ((array)$field_address as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>
  </div>
</div>

this code actually handles multiple items for each field. but if you wanted to just print what you have in the first one then this would do it.

<?php print $field_address[0]['view'];

use the var_dump($node) to see what fields you have available to print out then just print the fields direct as above. I presume this works for 5.1 as this is how I do it in 4.7

hope that helps.

Phillip Mc’s picture

Hi Sundhars,

Can I recommend the contemplate.module?

I find it very useful for customising the layout of $content.

It does something very similar to what the other poster mentioned..i.e. display all the fields available to the node so you can customisethe layout for everything, but, it also allows you to customise the RSS output feeds for different content types, as well as the teaser/full node layout in a simple to use settings page.

I usually use the contemplate.module when developing/building a site and then copy the layouts into node-type.tpl.php files - so I can remove the module when the site is ready.

phil

sundhars’s picture

Hi,

Thanks to both of then , i got the solution with contemplate module .