Print the content-type name or label with the 'submitted' info

I'm sure there is a better way of doing this ... but I can't find it :) so in the meantime, here is a hack of this theme snippet.

add these lines into node.tpl.php where you want the node-type label to appear.

<?php   if (theme_get_setting('toggle_node_info_' . $node->type)) : ?>
<?php   if ($node->type == 'book') { print '<div class="info"> brochure </div>'; }
       elseif (
$node->type == 'flexinode-2') { print '<div class="info"> webhelp </div>'; }
       elseif (
$node->type == 'flexinode-3') { print '<div class="info"> handbook </div>'; }
       elseif (
$node->type == 'flexinode-6') { print '<div class="info"> inventory item </div>'; }
       elseif (
$node->type == 'flexinode-7') { print '<div class="info"> meeting </div>'; }
       elseif (
$node->type == 'flexinode-9') { print '<div class="info"> task </div>'; }
       elseif (
$node->type == 'flexinode-14') { print '<div class="info"> discussion </div>'; }
       elseif (
$node->type == 'flexinode-13') { print '<div class="info"> social event </div>'; }
       else  { print
'<div class="info"> node type unknown</div>'; } ?>

<?php endif; ?>

if it's not obvious, the type == 'flexinode-2' refers to the drupal name for a content type and the second part (here webhelp) is whatever you write in between the DIV tags.

Yes I know there will be a simple way of calling a simple $node->type->name for a given node but I cannot find it in the documentation or forums.

I don't know what the first and last lines do, but the script didn't work without them.

;-j

In Drupal 5 and 6

Chill35 - June 16, 2008 - 23:22

Rely on this function instead: http://api.drupal.org/api/function/node_get_types/

<?php
print node_get_types('name', $node);
?>

If you don't want 'page' to appear for pages, use this:

<?php
print $node->type != 'page' ? node_get_types('name', $node) : '';
?>

If you wish to exclude more than 1 content types from being printed (their name, that is!), use something like this:

<?php
if (!in_array($node->type, array('story', 'page'))) { print node_get_types('name', $node); }
?>

 
 

Drupal is a registered trademark of Dries Buytaert.