CREATE CONTENT navigation block
Last modified: February 9, 2008 - 14:29
You may use this code to make a block containing add content links.
This may look like the page at node/add
<?php
global $user;
$types = node_get_types();
// If no (valid) node type has been provided, display a node type overview.
foreach ($types as $type) {
if (function_exists($type->module .'_form') && node_access('create', $type->type)) {
$type_url_str = str_replace('_', '-', $type->type);
$title = t('Add a new @s.', array('@s' => $type->name));
$out = '<li>'. l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('title' => $title)) .'<br/>';
$out .= filter_xss_admin($type->description) .'<br/> </li>';
$item[$type->type] = $out;
}
}
if (isset($item)) {
uksort($item, 'strnatcasecmp');
$output = t('Choose the appropriate item from the list:') .'<ul>'. implode('', $item) .'</ul>';
}
else {
$output = t('No content types available.');
}
print $output;
?>