Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By JamesRobertson on
I wish to create an invoice template.
I have used hook_theme.
/**
* Implements hook_theme().
*/
function MyModule_theme($existing, $type, $theme, $path) {
return array(
'MyModule_invoice' => array(
'variables' => array('invoice_content'=>NULL),
'template' => 'templates/invoice',
),
);
}
Unfortunately, the template is showing in the content region/block of my site.
I need the template to be a completely separate html page outside of my site theming, so that it can be printed off without the site appearance.
I hope this makes sense and I am sure there is a very easy solution...
Comments
Solution...
http://drupal.stackexchange.com/questions/21339/blank-page-template-for-...
Not sure how this relates to
Not sure how this relates to the question.
Possibly my original query
Possibly my original query was not clear enough. There are times when we need to produce pages which do not have the appearance of the site - i.e no menus, no logo, no side bars...
Such a time would be when you want produce a clean looking invoice.
If I create a template it will appear in the $page['content'] area of the website by default (it appears to me). However, using template_preprocess_html and template_preprocess_page I am able to create a stand-alone page.
More in line with the "Drupal
More in line with the "Drupal way" is to have the menu callback that generates the page is to have it render/print the page instead of returning the page content.
Theme functions/templates do
Theme functions/templates do not (or at least should not) determine the placement of content.
Placement between main content and blocks is determined how the invoice is generated. An invoice that is meant to be a page should have a path and callback defined in hook_menu. Content in blocks would be defined in the hook_block_* hooks.