Skip to main content
order further suggestions by relevance
Source Link
Mario Steinitz
  • 4.8k
  • 1
  • 15
  • 34

From the naming of your module and template file, I suppose you want to add a template for a custom block returned by your module.

The reason, that your template is found by adding it to the theme is not that you implemented hook_theme() in your custom module, but the way you named the template. It is found by the theme registry's template suggestions used for the block within your panels pane.

If you want your own theme hook jsblock_custom_theme to be applied to the block, you will have to add the theme hook to your block output by using the theme() function. An abstract example:

/**
 * Implements hook_block_view().
 */
function jsblock_block_view($delta='') {
  $block = array();

  switch($delta) {
    case 'jsblock_myblock''jsblock_jsblock':
      $variables = array();

      // Prepare your block variables here.

      $block['content'] = theme('jsblock_custom_theme', $variables);
      break;
  }

  return $block;
}

Some further suggested checks/improvements:

  • Check your template path: Keep in mind that drupal_get_path returns a path without trailing slashes. You will have to add a / to your path.
  • Place your template in a theme subfolder to keeping a cleaner module structure.
  • Don't name the template like the natively used template suggestions to avoid collisions while the theme tries overriding templates.
  • Check your template path: Keep in mind that drupal_get_path returns a path without trailing slashes. You will have to add a / to your path.

From the naming of your module and template file, I suppose you want to add a template for a custom block returned by your module.

The reason, that your template is found by adding it to the theme is not that you implemented hook_theme() in your custom module, but the way you named the template. It is found by the theme registry's template suggestions used for the block within your panels pane.

If you want your own theme hook jsblock_custom_theme to be applied to the block, you will have to add the theme hook to your block output by using the theme() function. An abstract example:

/**
 * Implements hook_block_view().
 */
function jsblock_block_view($delta='') {
  $block = array();

  switch($delta) {
    case 'jsblock_myblock':
      $variables = array();

      // Prepare your block variables here.

      $block['content'] = theme('jsblock_custom_theme', $variables);
      break;
  }

  return $block;
}

Some further suggested checks/improvements:

  • Place your template in a theme subfolder to keeping a cleaner module structure.
  • Don't name the template like the natively used template suggestions to avoid collisions while the theme tries overriding templates.
  • Check your template path: Keep in mind that drupal_get_path returns a path without trailing slashes. You will have to add a / to your path.

From the naming of your module and template file, I suppose you want to add a template for a custom block returned by your module.

The reason, that your template is found by adding it to the theme is not that you implemented hook_theme() in your custom module, but the way you named the template. It is found by the theme registry's template suggestions used for the block within your panels pane.

If you want your own theme hook jsblock_custom_theme to be applied to the block, you will have to add the theme hook to your block output by using the theme() function. An abstract example:

/**
 * Implements hook_block_view().
 */
function jsblock_block_view($delta='') {
  $block = array();

  switch($delta) {
    case 'jsblock_jsblock':
      $variables = array();

      // Prepare your block variables here.

      $block['content'] = theme('jsblock_custom_theme', $variables);
      break;
  }

  return $block;
}

Some further suggested checks/improvements:

  • Check your template path: Keep in mind that drupal_get_path returns a path without trailing slashes. You will have to add a / to your path.
  • Place your template in a theme subfolder to keeping a cleaner module structure.
  • Don't name the template like the natively used template suggestions to avoid collisions while the theme tries overriding templates.
Source Link
Mario Steinitz
  • 4.8k
  • 1
  • 15
  • 34

From the naming of your module and template file, I suppose you want to add a template for a custom block returned by your module.

The reason, that your template is found by adding it to the theme is not that you implemented hook_theme() in your custom module, but the way you named the template. It is found by the theme registry's template suggestions used for the block within your panels pane.

If you want your own theme hook jsblock_custom_theme to be applied to the block, you will have to add the theme hook to your block output by using the theme() function. An abstract example:

/**
 * Implements hook_block_view().
 */
function jsblock_block_view($delta='') {
  $block = array();

  switch($delta) {
    case 'jsblock_myblock':
      $variables = array();

      // Prepare your block variables here.

      $block['content'] = theme('jsblock_custom_theme', $variables);
      break;
  }

  return $block;
}

Some further suggested checks/improvements:

  • Place your template in a theme subfolder to keeping a cleaner module structure.
  • Don't name the template like the natively used template suggestions to avoid collisions while the theme tries overriding templates.
  • Check your template path: Keep in mind that drupal_get_path returns a path without trailing slashes. You will have to add a / to your path.