1

I created an content type of name "profile", where it has fields Profile Name, Image , message , body.

It displays in this format attached image_1 Default format of Drupal 7

Now how can we arrange or make change in custom format like below image image_2 how can we displayed to end user

custom made profile

1 Answer 1

4

you can use node--NAMECONTENTTYPE.tpl.php in your directory template. Please see this documentation and comments about templates in Drupal 6 http://drupal.org/node/17565, this will give you a guidance to recognize some few differences with Drupal 7.

to be more detailed, you can copy/paste to your theme directory the file node.tpl.php (located in modules > node or already located inside your theme directory) and rename it according your content type. for example, if the Content Type is Article the name will be node--article.tpl.php

already inside in node--article.tpl.php you can see the variable $content or you can use $node. $content (or $node) variable is carrying the content of your node. you can use print_r($content); to see the list of the fields that you can use to your node (or if you use Devel module, is best use dsm($content);)

see this example:

I have a field called field_demotext1, then this is the way that I can use to call their respective value inside any custom html zone of my node layout:

echo $content['field_demotext1']['#items'][0]['value'];

enter image description here

here is the example of zone in the node--article.tpl.php where you can use a custom html:

  <div class="content clearfix"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      //print render($content); comment to hide all content
      echo $content['field_demotext1']['#items'][0]['value']; //will only show field_demotext1 value
    ?>
  </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.