You are here

function flag_phptemplate_adapter in Flag 5

In Drupal 5 it is possible to put a phptemplate_flag() function in your 'template.php', and within that function instructions to make Drupal scan for various template files for theming a flag.

The syntax for that phptemplate_flag() is somewhat arcane --and may need updating when our API changes-- so here we provide a ready-made version of that funtion. You should call it from your phptemplate_flag(). See 'theme/README.txt'.

File

./flag.module, line 706
The Flag module.

Code

function flag_phptemplate_adapter($flag, $action, $content_id, $after_flagging = FALSE) {

  // Prepare the variables to be available in the template.
  $variables = array(
    'flag' => $flag,
    'action' => $action,
    'content_id' => $content_id,
    'after_flagging' => $after_flagging,
  );
  flag_template_preprocess('flag', $variables);

  // Prepare an array of suggested templates to try.
  $suggestions = array();
  foreach ($flag
    ->theme_suggestions() as $suggestion) {
    $suggestions[] = str_replace('_', '-', $suggestion);
  }
  $suggestions = array_reverse($suggestions);

  // Hand control to the phptemplate engine.
  $output = _phptemplate_callback('flag', $variables, $suggestions);

  // Finally, handle Drupal 5's jQuery bug. See explanation in theme_flag().
  $output = strtr($output, "\r\n", '  ');
  return $output;
}