Posted by convoke on May 18, 2011 at 5:44pm
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
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;
?>
The Boise Drupal Guy!
not work
Hi this code not working in my website.
$human_name = node_get_types('name', $type);
In Drupal 7
Hi,
In drupal 7, use node_type_get_name to extract Real Content type name from machine name.
Example please...
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
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
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:
<?phpprint node_type_get_name($type);
?>