I'm trying to create a new page template for a custom form I'm building in my module. My goal is to use create something like a new page.tpl.php
for this specific form and it looks like this method is creating the equivalent of a custom node.tpl.php
within the content area of my site instead of generating a separate page template.
For example
/*
* Implements hook_menu
*/
function mymodule_menu() {
$items = array();
$items['foo/my_custom_form'] = array(
'title' => 'My custom form',
'page callback' => 'mymodule_custom_page',
'access callback' => TRUE, // Everyone has access.
);
return $items;
}
function mymodule_custom_page(){
return theme('mymodule_template');
return drupal_get_form('mymodule_form');
}
/*
* Implements Hook_theme
*/
function mymodule_theme() {
return array(
'mymodule_template' => array(
'template' => 'custompage', // template file called custompage.tpl.php
'arguments' => array(),
),
);
}
function mymodule_form($node, &$form_state){
//my form in here
}
I'm having an issue with the form not appearing.
Maybe I'm going down the wrong path and should be trying to create function in my theme's template.php
, and then use a hook_preprocess_page
to set some variables to create a page--custom.tpl.php
for my form?
I can achieve what I'm trying to do by making some configuration changes to some blocks and redrawing the content area with CSS, but not sure if that's the best practice.
return
does exactly what it says on the tin. It returns from the function, and any code after it is ignored. Soreturn drupal_get_form('mymodule_form');
can never be executed. Your question about theming is quite a broad one, I'd recommend starting at the Theming Guide Docs. Also check out the Simple PHP tutorial to make sure you're happy with usage of the language – Clive♦ Mar 30 '13 at 12:57