You can change the output through preprocessing, for example in your theme's template.php file, or in your custom module (see also: https://api.drupal.org/api/drupal/modules!system!theme.api.php/function/hook_preprocess_HOOK/7).
The $variables['content'] variable contains the content of the block to be displayed. The individual elements come from $variables['elements']. If you add:
debug(array_keys($variables['elements']));
to the script, you get the following output:
array (
0 => 'whois_form',
1 => 'whois_lookup_data',
2 => '#block',
3 => '#weight',
4 => '#theme_wrappers',
5 => '#children',
)
When looking at these in detail, you see that $variables['elements']['#children'] is comprised of $variables['elements']['whois_form']['#children'] and $variables['elements']['whois_lookup_data']['#children'].
Ultimately, $variable['content'] is comprised of $variable['elements']['#children'] (see also https://api.drupal.org/api/drupal/modules!block!block.module/function/template_preprocess_block/7)
So, there are two options:
- Alter $variables['elements']['whois_lookup_data']['#children'], and recreate $variable['elements']['#children']
- Alter $variable['elements']['#children'] directly.
I chose the second option below.
To use the hook_preprocess_block hook, as shown below, the core module "Block" needs to be enabled.
If used in a module, in yourmodule.info:
name = Whois Alter Module
description = A module to change the output of whois.
core = 7.x
package = Drupal 7 Misc
files[] = whois_alter.module
dependencies[] = block
dependencies[] = whois
In whois_alter.module:
<?php
// $Id$
/**
* @file
* A module to demonstrate hook_preprocess_block to alter the output of another module
*
* This module alters the output of the whois module
*/
/**
* Implements hook_help().
*/
function whois_alter_help($path, $arg) {
if ($path == 'admin/help#whois_alter') {
return t('A module to alter whois output.');
}
}
/**
* Implements hook_preprocess_block().
*/
function whois_alter_preprocess_block(&$variables, $hook){
if (isset($variables['elements']['whois_lookup_data'])) {
$whois_modified = whois_alter_modify_whois($variables['elements']['#children']);
$variables['elements']['#children'] = $whois_modified;
$variables['content'] = $variables['elements']['#children'];
}
}
function whois_alter_modify_whois($content) {
// do what you want to do to modify the output
return $altered_content;
}
For Theme preprocessing, just use the functional part of the module in template.php:
function yourtheme_preprocess_block(&$variables, $hook){
if (isset($variables['elements']['whois_lookup_data'])) {
$whois_modified = yourtheme_modify_whois($variables['elements']['#children']);
$variables['elements']['#children'] = $whois_modified;
$variables['content'] = $variables['elements']['#children'];
}
}
function yourtheme_modify_whois($content) {
// do what you want to do to modify the output
return $altered_content;
}