I have a site in Drupal 7 and I have created a custom module for a functionality that I need. Usually, I create custom modules and I create a new page to show them, using the following code:
function my_custom_module_theme() {
$items = array();
$items['my_custom_module'] = array(
'render element' => 'form',
'path' => drupal_get_path('module', 'my_custom_module') . '/templates',
'template' => 'my_custom_module-template',
);
return $items;
}
function my_custom_module_menu() {
$items = array();
$items['my_custom_module'] = array(
'title' => t('my_custom_module'),
'page callback' => 'drupal_get_form',
'page arguments' => array('my_custom_module'),
'access callback' => TRUE,
);
$items['my_custom_module'] = array(
'title' => t('my_custom_module'),
'page callback' => 'drupal_get_form',
'page arguments' => array('my_custom_module_empty_form'),
'access callback' => TRUE,
);
return $items;
}
function my_custom_module_preprocess_page(&$variables, $hook) {
$alias = drupal_get_path_alias($_GET['q']);
if ($alias == "my_custom_module") {
$variables['theme_hook_suggestions'][] = 'my_custom_module';
$variables['show_messages'] = TRUE;
}
}
function my_custom_module_empty_form($form_state) {
$form = array();
return $form;
}
and my module appears on mysite/my_custom_module .
What I want to achieve now is to add my custom module at the bottom of an existing node, which has it's own content and functionality.
What should I add to my_custom_module-template.tpl.php or in my node--xx.tpl.php to display my custom module inside the node?
I have already used
<?php
$nid = xx; // NOTE :: Hard coded, but need to be variable!!
print drupal_render(node_view(node_load($nid)));
?>
from a similar Stack overflow question, but it does the opposite of what I want, it renders the node inside the module.