templates - Custom Menu tabs in Drupal user profile page -


i want add menu item along side [view] [edit] [files] ... menu links @ top of user profile page. when user clicks it, should behave others, in doesn't launch new page, menu item clicked on (let's call "funky button") turns greyish , user remains in user profile area.

i've created hook below:

function my_module_funky() {     // todo: do? }   function my_module_menu() {      $items['user/%user/funky'] = array(         'title' => t('funky button'),         'page callback' => 'my_module_funky',         'page arguments' => array(1),         'access callback' => true,         'access arguments' => array('access funky button'),         'type' => menu_local_task,     );      return $items; } 

so above code snippet adds button -- can't figure out how display view , edit buttons display content. thanks!

your callback needs return string containing html code of page display, example:

function my_module_funky($user){  drupal_set_title('funky page');  return 'this $user value: <pre>'.var_export($user, true).'</pre>'; } 

$user comes line 'page arguments' => array(1) of hook_menu implementation transmits value of %user wildcard first argument of page callback.


if it's complex page, may want create theme function template file, way can store page's code in .tpl.php file, makes easier maintain (especially if module creates many such custom pages).

this have benefit allow themes customize page output providing own version of .tpl.php file if module becomes popular or other modules preprocess page add/modify variables.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -