I need to create new field in a Node template and don't need the Title and Body fields, is there a way to remove them?
please see the attached image.

CommentFileSizeAuthor
#1 node_fields.jpg27.73 KBvako
node_fields.jpg89.23 KBvako

Comments

vako’s picture

StatusFileSize
new27.73 KB

Sorry I attached the wrong image to the topic. The correct one is attached here.

choster’s picture

You can suppress the Body by removing the label for it when defining the node type.

Probably the easiest way to suppress the node title is to use http://drupal.org/project/auto_nodetitle .

markus_petrux’s picture

Status: Active » Fixed

Good advice, choster. Thanks!

calte’s picture

To elaborate on the above answer if you select 'Automatically generate the title if the title field is left empty' and submit '<-?php ?> (without the -) into the 'Pattern for the title:' box (within 'Administer / Content management / Content types / 'edit' / Automatic title generation') you will get no title generated. This gives you the option of submitting a title-less node.

I use this personally for when I 'sticky to top of lists' as an intro to something like a blog page when I don't particularly want to edit my css to apply (display: hidden). It also keeps your code a tad cleaner. If you're really picky you can have node.tpl.php remove the < h2 > tags when the title is empty see below:

Change

<?php if (!$page): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>

to

<?php if (!$page || !empty($title)): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
calte’s picture

It might not hurt to mention that I took '!$page' right out of there.
If I want a page with or without a title, I now have that option, as well as every other content type.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.