display content type name?

Events happening in the community are now at Drupal community events on www.drupal.org.
convoke's picture

I've created a child theme of Zen for a website I'm working on.

What I'm trying to do right now is display the content type name (not machine name!!!) below the title. The $type variable only returns the machine name... is there a way to return the "display" name of a content type?

For example, the machine name for one of my content types is "article", but the display name is "Stuff". How can I go about returning "Stuff" instead of "article"?

Comments

If you're using Drupal 6, you

Garrett Albright's picture

If you're using Drupal 6, you can use node_get_types():

<?php
$human_name
= node_get_types('name', $type);
?>

Drupal 7 is a smidge trickier - use node_type_get_types(), which will return an array full of data on all of a site's types. Then pluck the "name" attribute from the relevant type.

<?php
$types
= node_type_get_types();
$human_name = $types[$type]->name;
?>

not work

mayur.pimple's picture

Hi this code not working in my website.
$human_name = node_get_types('name', $type);

In Drupal 7

jdjeet's picture

Hi,

In drupal 7, use node_type_get_name to extract Real Content type name from machine name.

Example please...

monalisab's picture

Hi Jeet,

Could you please provide an example for node_type_get_name use.
I am getting an multidimensional array by using node_type_get_types() .

But unable to get only content type names for my custom admin configuration form page. :(

Its solved now... I just

monalisab's picture

Its solved now...

I just wanted it as a check-box list for custom form.

// Load all node types.
$types = node_type_get_types();

$checkboxes = array();
 
foreach ($types as $val) {
    $checkboxes[$val->type] = $val->name;
}

As jdjeet says use

vaudaville's picture

As jdjeet says use node_type_get_name
For Drupal 7 the following will display the human readable name of the content type in a node when added to node.tpl.php:

<?php
print node_type_get_name($type);
?>