Community Documentation

How to convert an _auth_help hook

Last updated November 19, 2007. Created by puregin on May 30, 2005.
Edited by AjK. Log in to edit this page.

Okay, you have written your Distributed Authorization module, and given us a great help text for it and I had to go and ruin it all by changing the help system. What a terrible thing for me to do. How do you convert it?

It is not that hard. There are two places you have to deal with:

  1. The text inside the _auth_help hook needs to be moved inside the _help hook under the section user/help#<modulename> and
  2. You have to change the _page hook, which normally displays that help text, to find your text in a new location by changing the function call <modulename>_auth_help() to <modulename>_help("user/help#<modulename>").

See, it is not THAT terrible.

An example:

<?php
function exampleda_page() {

 
theme("header");
 
theme("box", "Example DA", exampleda_auth_help());
 
theme("footer");
}

function
exampleda_auth_help() {
 
$site = variable_get("site_name", "this web site");
 
$html_output = "
  <p>This is my example Distributed Auth help. Using this example you cannot login to <i>%s</i> because it has no _auth hook.&</p>

<p><u>BUT</u> you should still use Drupal since it is a <b>GREAT</b> CMS and is only getting better.</p>

<p>To learn about about Drupal you can <a
href=\"www.drupal.org\">visit the site</a></p>"
;
  return
sprintf(t($html_output), $site);
}
?>

<?php
function exampleda_page() {

 
theme("header");
 
theme("box", "Example DA", exampleda_help('user/help#exampleda'));
 
theme("footer");
}

function
exampleda_help($section) {
 
$output = "";

  switch (
$section) {
    case
'user/help#exampleda':
     
$site = variable_get("site_name", "this web site");
     
$output .= "<p>This is my example Distributed Auth help. Using this example you cannot login to %site because it has no _auth hook.</p>";
     
$output .= "<p><u>BUT&</u> you should still use Drupal
since it is a <b>GREAT</b> CMS and is only getting better.</p>"
;
     
$output .= "<p>To learn about about Drupal you can
visit %drupal.</p>"
;
     
$output = t($output, array("%site" => "<i>$site</i>",
"%drupal" => "<a href=\"www.drupal.org\">visit the site</a>"));
      break;
  }
  return
$output
}
?>

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.