erier
erier

Reputation: 1754

Drupal7 | Custom Module | How to Display Template?

I'm having trouble figuring out how to display a template that lives inside of my custom module.

This is what I have:

<?php

function brl_footer_theme($existing, $type, $theme, $path) {
    $theme = array();

  $theme['brl_footer'] = array(
    'render element' => 'content',
    'template' => 'brl-footer',
    'path' => drupal_get_path('module', 'brl_footer'),
   );

  return $theme;
}

/**
 * Implements hook_block_info().
 */
function brl_footer_block_info() {
    $blocks = array();

  $blocks['brl_footer'] = array(
    'info' => t('Custom Footer'),
  );

  return $blocks;
}

I have a template file in the module called brl-footer.tpl.php

It contains very basic HTML:

<h1>here's some content</h1>

Is it possible to display my template through the custom block 'brl_footer' that's being created?

The custom block is active and has been assigned to the proper region.

Any help on this would be hugely appreciated -

Upvotes: 0

Views: 102

Answers (1)

reallyxloco
reallyxloco

Reputation: 114

You'll need to implement hook_block_view to define what gets displayed in your block.

Also, if your template is just static content, you don't need to specify a "render element" or "variables" for your theme hook (though you could still make variables in a preprocess function).

Upvotes: 1

Related Questions