How to convert an _auth_help hook
Last modified: November 19, 2007 - 15:01
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:
- The text inside the _auth_help hook needs to be moved inside the _help hook under the section
user/help#<modulename>and - 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
}
?>