I'm working on my first D7 site and am trying to replace page titles with images using the 6.x code at http://drupal.org/node/221854 but I'm running into a problem that I haven't seen with D6. It appears that it's not possible to make any changes to $variables['title'] such as sanitizing the text and replacing the spaces with underscores, as is necessary to replace the title with an image.
Here's my code from my template.php file, it's certainly possible that I'm missing some key difference between D6 & D7:
// Prepare some general title text for use as a file name.
// Remove special HTML characters, trim whitespace, convert to lower-case
// repace spaces with underscores.
function clean_title($string)
{
$replace_chars = array("&", ":", ",", "'");
$cleanString = htmlspecialchars_decode( strtolower(trim($string)), ENT_QUOTES );
$cleanString = str_replace($replace_chars, "", $cleanString);
return str_replace(' ', '_', $cleanString );;
}
function MYTHEME_preprocess_page(&$variables) {
// substitute node title with an image, if a suitable replacement can be found.
// save original title text for use in head and breadcrumb.
$variables['breadcrumb_title'] = $variables['title'];
$variables['head_title'] = $variables['title'];
// Substitute title only for nodes...
$titleFile = clean_title($variables['title']) . '.png';