I have developed a module in Drupal 7.

Now, I want to add a custom themed-page in the admin panel of Drupal.

I have added a page using admin_menu():

function newsletter_menu()
    $info = array();

    $info['admin/reports/newsletter'] = array(
        "title" => "Number of Registered Users for Newsletter",
        "description" => "",
        "page callback" => "newsletter_admin_content_block",
        'page arguments' => array('newsletter_admin'),
        'access arguments' => array('administer newsletter settings'),
        'type' => MENU_NORMAL_ITEM

    return $info;

It works all well. But my problem is:

I have a template file newsletter.admin.tpl.php which I want to use a the template for this page. But I don't know how should I achieve it. Can anyone help?

2 Answers 2


Have a look at this question on stackoverflow: https://stackoverflow.com/questions/5305114/drupal-7-how-to-load-a-template-file-from-a-module

It basically comes down to this:

  1. Implement hook_theme()
  2. Create the template file
  3. At the end of your newsletter_admin_content_block call theme() with your template key (as defined in hook_theme()) as first argument and any additional variables that you need in your template as an array.


function hook_theme($existing, $type, $theme, $path) {
  return array(
    'newsletter_admin_content_template' => array(
      'variables' => array('var1' => NULL, 'var2' => NULL, ...),
      'template' => 'newsletter-admin-content-template'

And at the end of your menu callback:

return theme('newsletter_admin_content_template', array(
  'var1' => $var1,
  'var2' => $var2,
  • I have already implemented this technique, though it doesn't work. Seeing some other places on the net suggesting the same technique as yours, I know am sure that the problem is my code and not the technique itself. Apr 6, 2015 at 13:55
  • 1
    Be sure to clear the cache. Also, do not add ".tpl.php" to the template name in hook_theme(). What else? There is also the question of where your template file is stored in your file system. For a custom module, it is logical to put it into your module directory and specify the pathkey in hook_theme().
    – berliner
    Apr 6, 2015 at 13:57
  • Yes it was a caching problem. Apr 6, 2015 at 14:02

you could try page--admin--reports--newsletter.tpl.php (refer to Template Suggestions and Arguments for some more details).

Or just use a theme_hook_suggestion (if really needed, with hook_init() and menu_get_item()).

In any case, be sure to place it in the templates folder of your theme and don't forget to clear the cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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