6.x node.pages.inc theme_node_add_list($content)
7.x node.pages.inc theme_node_add_list($variables)

Returns HTML for a list of available node types for node creation.

Parameters

$variables: An associative array containing:

  • content: An array of content types.

Related topics

1 theme call to theme_node_add_list()
node_add_page in modules/node/node.pages.inc
Page callback: Displays add content links for available content types.

File

modules/node/node.pages.inc, line 44
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function theme_node_add_list($variables) {
  $content = $variables['content'];
  $output = '';
  if ($content) {
    $output = '<dl class="node-type-list">';
    foreach ($content as $item) {
      $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
      $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
    }
    $output .= '</dl>';
  }
  else {
    $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array(
      '@create-content' => url('admin/structure/types/add'),
    )) . '</p>';
  }
  return $output;
}

Comments

evinsoft’s picture

/** 
 * Override theme_node_add_list()
 * This theme function is called to generate the contents of node/add page
 *
 * Add node type's class to each list item
 */
function MY_THEME_node_add_list($content) {
  $output = '';
  if ($content) {
    $output = '<dl class="node-type-list">';
    foreach ($content as $item) {
       
      //The node type is not passed to this function, but I can get it from access
      //argument! which is something like array('create', 'node_type') !!
      $access_arguments = unserialize($item['access_arguments']);
      $node_type = $access_arguments[1];
       
      $output .= "<div class=\"node-add-{$node_type}-wrapper node-add-item-wrapper\">";
      $output .= "<div class=\"node-add-{$node_type}-inner node-add-item-inner\">";
      $output .= "<dt class=\"node-add-{$node_type}\">". l($item['title'], $item['href'], $item['localized_options']) .'</dt>';     
      $output .= "<dd class=\"node-add-{$node_type}\">". filter_xss_admin($item['description']) .'</dd>';
      $output .= "</div><!-- /.node-add-{$node_type}-wrapper -->";
      $output .= "</div><!-- /.node-add-{$node_type}-inner -->";
    }
    $output .= '</dl><div style="clear: both;"></div>';
  }
  return $output;
}