Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am using Drupal 6, and I have created a custom module which is in the "sites\all\modules\custom" folder; in the same folder there is also the custom.tpl.php file.

I want to place the custom.tpl.php file in the theme folder.

Here is my code:

function custom_menu() {
  $items = array();

  $items['custom'] = array(
    'page callback' => 'custom_page',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function custom_page() {
  $result = db_query('SELECT * from node');
  return theme('custom', array('output' => $result));
}

function custom_theme() {
  return array(
    'custom' => array(
      'arguments' => array('output' => NULL),
      'template' => 'custom',
     ),
  );
}

function template_preprocess_custom(&$variables) {}
share|improve this question
add comment (requires an account with 50 reputation)

2 Answers

Please give path key in theme registry.

function custom_theme() {
  return array(
    'custom' => array(
      'arguments' => array('output' => NULL),
       template' =>  path_to_theme() . '/custom',
      'path' => '/'
     ),
  );
}
share|improve this answer
add comment (requires an account with 50 reputation)

Well you can place in the theme folder or you can leave it in the module. Drupal will look in both places. So if your implementation of hook_theme is a template, Drupal will look for the following files:

  • themes/bluemarine/custom.tpl.php
  • modules/custom/custom.tpl.php

If you read the documentation for hook_theme you'll get your answer for the question when you get to the path key:

path: [...] Ordinarily the module or theme path will be used [...]

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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