I am on Drupal 7. I want to create a page that lists its children, the same way you see the list of links in 'admin/structure' (Blocks, Content types, Entity types ...).

I have modified child 1 and child 2. They aren't really important for this example.

on mymodule.module I have inside function mymodule_menu():

  $items['admin/mymodule'] = array(
    'title' => 'My module parent page',
    'page callback' => 'mymodule_admin_page',
    'access callback' => 'mymodule_admin_list',
    'access arguments' => array(1),
    'file' => 'mymodule.admin.inc',

  // Child 1
  $items['admin/mymodule/child1'] = array(
    'title' => 'Child 1',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymodule_something_01', 1),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'mymodule.admin.inc',

  // Child 2
  $items['admin/mymodule/child2'] = array(
    'title' => 'Child 2',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymodule_something_02', 1),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'mymodule.admin.inc',

Then, on mymodule.admin.inc, I have this function:

function mymodule_admin_page() {
  $item = menu_get_item();
  if ($content = system_admin_menu_block($item)) {
    $output = theme('mymodule_admin_list', array('content' => $content));        
    // This gets printed on the page
    drupal_set_message('This gets printed on the page');
  else {
    $output = t('You do not have any administrative items.');
    // This doesn't get printed on the page because my base page has children.
    drupal_set_message('This doesnt get printed on the page because my base page has children.');
  return $output;

Finally, according to documentation I have read, I should add a function like the one below:

function theme_mymodule_admin_list($variables) {

  $content = $variables['content'];
  $output = '';
  // This doesn't get printed on the page...
  drupal_set_message('this doesnt get printed... Why???');

  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>';

  return $output;

Check my drupal_set_message above. Messages on function mymodule_admin_page get printed, but messages on theme_mymodule_admin_list don't get printed... Actually, admin/mymodule responds as a page, but instead of displaying links to its children, it will display a blank page...

I must be missing something, but I really don't know what. Thank you!



I am posting the solution below. Thank you, Geoff, for your comment. It did the trick! I was missing one of the pieces in this puzzle, which was the mymodule_theme function.

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'mymodule_admin_list' => array(
      'variables' => array('content' => NULL),
      'file' => 'mymodule.admin.inc',
  • 1
    might seem like stupid questions, but is theme_mymodule_admin_list() in your active themes template.php and have you flushed the cache? – Geoff Sep 7 '14 at 1:00
  • Hey! Not stupid at all, your hint made all the difference! I was missing one of the pieces in the puzzle. Please, add your comment as an answer and I will check it as approved. Thank you! I am adding a more complete solution into my own question. – Marcos Buarque Sep 7 '14 at 1:23
  • what I wrote wasn't really a solution even if it got you thinking in the right direction, so you can add your own if you like. – Geoff Sep 7 '14 at 2:03
  • Well, ok, but pointing the right direction was really an eye-opener. Thank you. If you would like to post it as an answer, I will accept it as solved. Best regards. – Marcos Buarque Sep 8 '14 at 11:52

Another Solution here would be to do what the admin pages do for those pages

$items['admin/somemodule'] = array(
 'title' => 'My Module Section',
 'description' => 'Manage My Module',
 'page callback' => 'system_admin_menu_block_page',
 'access arguments' => array('access administration pages'),
 'file path' => drupal_get_path('module', 'system'),
 'file' => 'system.admin.inc',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.