0

I've got custom content-type with several groups and fields.

I want to change default display of that content-type. In which file can I find appropriate code?

  • From reading through your other questions, it seems to me that you don't actually grasp any of the core concepts of Drupal. I would suggest a thorough read of the Documentation, especially the Theming Guide, and possibly pick up a copy of Pro Drupal Development, which is pretty much the Drupal bible. – Chapabu Aug 10 '13 at 19:52
4

You need to create that file - copy the node.tpl.php file to

node--your_content_type.tpl.php

and take it from there. Here's the relevant page from the handbook for Drupal 7

https://drupal.org/node/1089656

Alternatively, if you're just getting started with node templates, you may find it easier to install and enable the content templates module so you can add and modify node templates from the administrator backend:

https://drupal.org/project/contemplate

The Content Template (a.k.a. ConTemplate) module allows modification of Drupal's teaser and body fields using administrator defined templates. These templates use PHP code and all of the node object variables are available for use in the template. An example node object is displayed and it is as simple as clicking on its properties to add them to the current template.

  • Yet, whether content templates module allows me to change something more than style, e.g. adding new functions or HTML code? – user19455 Aug 8 '13 at 21:04
  • 1
    you don't want to add functionality to a content template - you should keep that separate from your theme layer for maintanability. Both options above (template files and contemplate) give you option to add styles and html code, if you want to add logic and functionality, ex. PHP code, I would suggest using the first option and make a template file for your content type. – schnippy Aug 8 '13 at 21:22
0

As I see your question is regarding styling of fields. You can take help from module Field Formatter Class. It lets you apply class for field on manage display.

If you are intended to have control over your field by help of template files, then copy field.tpl.php from $base_url/modules/field/theme and put that into your theme folder.

Change the name to have effect on your particular field like field--FIELDNAME.tpl.php, where FIELDNAME will be machine name of your field, for example field--body.tpl.php.

Insert/modify the CSS classes in there and style accordingly.

0

Try something like hide($content['field_group-machine_name']['field_machine_name']) inside the template file for your content type, for all the fields that are before the fields you want to render; then render those fields using print $content['field_group-machine_name']['field_machine_name'] and render the rest of the content.

By the way, why don't you just change the order in the content type display?

  • That was an example. I want to change my style dramatically. I tried what you wrote. It seems to be working. Yet, I've got two displays: Default and Teaser. When I change style in that file, e.g. hide($content['field_group-machine_name']['field_machine_name']', it is done in both displays. I want to change style only in default display. How can I do it? – user19455 Aug 10 '13 at 19:25
  • @user19455 [Add theme hook suggestion for node view mode] ( drupal.org/node/1503464) . I also think that using a new display will be much easier and a better solution – rreiss Aug 10 '13 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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