Last active
August 29, 2015 14:02
-
-
Save jonasdeherdt/f1ff24def935870a08c3 to your computer and use it in GitHub Desktop.
Basic module template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_permission | |
*/ | |
function jonasdeherdt_permission() { | |
return array( | |
'administer jonasdeherdt module' => array( | |
'title' => t('Administer jonasdeherdt module'), | |
'description' => t('Perform admin tasks for this module'), | |
), | |
); | |
} | |
/* | |
* Implements hook_node_view | |
*/ | |
function jonasdeherdt_node_view($node, $view_mode, $langcode) { | |
/*$node->content['simple_field'] = array( | |
'#type' => 'markup', | |
'#markup' => '<p>' . t('This is only text') . '</p>', | |
'#weight' => -10, | |
); | |
//krumo($node);*/ | |
} | |
/* | |
* Implements hook_menu | |
*/ | |
function jonasdeherdt_menu() { | |
$items = array(); | |
$items['node/%node/custom'] = array( | |
'title' => 'custom tab', | |
'description' => 'custom content', | |
'page callback' => 'jonasdeherdt_page', | |
'page arguments' => array(1), | |
'access callback' => 'node_access', | |
'access arguments' => array('view', 1), | |
'type' => MENU_LOCAL_TASK, | |
); | |
return $items; | |
} | |
/* | |
* Implements hook_theme | |
*/ | |
function jonasdeherdt_theme() { | |
return array( | |
'jonasdeherdt_item' => array( | |
'variables' => array('item' => NULL), | |
), | |
); | |
} | |
function theme_jonasdeherdt_item($variables) { | |
$output = '<div class="jsd"><h1>' | |
. $variables['title'] | |
. '</h1><p>' | |
. check_plain($variables['data']) | |
. '</p></div>'; | |
return $output; | |
} | |
function jonasdeherdt_page($node) { | |
$info = _jonasdeherdt_process_info($node); | |
$content = array(); | |
foreach($info as $item){ | |
$content[] = array( | |
'#type' => 'markup', | |
'#markup' => theme('jonasdeherdt_item', $item), | |
); | |
} | |
return $content; | |
} | |
function _jonasdeherdt_process_info($node) { | |
$info[] = array( | |
'title' => t('title of this content'), | |
'data' => 'lipsum dolor sit amet', | |
); | |
return $info; | |
} | |
/* | |
@End | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment