Maybe this is something you can already do - if so then instructions would be great. But if not, is there any way you could make textimage render images instead of page titles in
HTML - on the fly from the database as new pages are added?

This would be something I could utilise a lot!

Comments

dman’s picture

That's what it does.
You'll need to invoke it from your theme, with something like

<img src="/files/textimage/title_style_preset/<?php print $node->title; ?>" alt="<?php print $node->title; ?>" />

where you used to have the title

... I believe

adshill’s picture

Ok, great - thanks for that! Thats what I had hoped for and it looks great. However there is a further issue in that for the core drupal produced pages (/blog, /forum/*, /contact, /user/* etc..) the title doesn't show up - either a blank image or nothing at all. Works fine on all node pages and also on comments etc.

Any ideas?

dman’s picture

OK, that was rough code OTTOMH
Those pages do not have $node->title as they are not nodes.
Instead you want drupal_get_title().. or $title ... or whatever it was you deleted from there :)
I can't remember but it's in the original source

BradM’s picture

This is something similar I put together a while ago. It works for me, never got any responses to the original post but I think it's safe. ;)

http://drupal.org/node/134603

What it does: using the textimage module, this code auto-replaces all node titles with a fancy graphical title, and will split the title onto two to three lines if it exceeds a certain length. It also attempts to clean up the title a bit so the graphics are named safely in unix.

I modified it a bit since then, however. This is the new code I use:

function fancy_title($title) {

$fullttl = $title;
$origcut = '51';
$cut = '51';

$title = ereg_replace('\?', '', $title); // replace bad characters
$title = ereg_replace('\,', '', $title); // replace bad characters
$title = ereg_replace('\&#039;', '', $title); // replace bad characters
$title = ereg_replace('\&amp;', 'and', $title); // replace bad characters
$title = ereg_replace('\#', '', $title); // replace bad characters
$title = ereg_replace('\$', '', $title); // replace bad characters
$title = ereg_replace('\'', '', $title); // replace bad characters
$title = ereg_replace('\/', '-', $title); // substitute forward slashes with dashes
$title = ereg_replace(' ', '_', $title); // replace spaces with underscores
$title = strip_tags($title);
if (strlen($title) > $cut) {
	while (!preg_match("/_/", $title[$cut])) {
		$cut++;
		if (!$title[$cut]) {
			break;
		}
	}
	$title1 = substr($title, 0, $cut+1);
   	$title2 = substr($title, $cut+1, strlen($title));
   	if (strlen($title2) > $origcut) {
   		$newtitle = $title2;
   		while (!preg_match("/_/", $newtitle[$origcut])) {
		   	$origcut++;
	    	if (!$newtitle[$origcut]) {
				break;
	   		}
   		}
   		$title2 = substr($newtitle, 0, $origcut+1);
   		$title3 = substr($newtitle, $origcut+1, strlen($newtitle));
   	}
   	$fancytitle = "<img src = '/path to/files/textimage/subtitles/$title1.jpg' title = '$fullttl' alt = '$fullttl'>";
	$fancytitle .= "<BR><img src = '/path to/files/textimage/subtitles/$title2.jpg' title = '$fullttl' alt = '$fullttl'>";
	if ($title3) {
		$fancytitle .= "<BR><img src = '/path to/files/textimage/subtitles/$title3.jpg' title = '$fullttl' alt = '$fullttl'>";
	}
} else {
  	$fancytitle = "<img src = '/path to/files/textimage/subtitles/$title.jpg' title = '$fullttl' alt = '$fullttl'>";
}
return $fancytitle;
}

This code goes within the template.php file -- you then call it from within node.tpl.php by using print fancy_title($title);. This way, if you have different node templates, you can pick and choose where you put it.

Note: the above only affects node titles.

You can also have it create fancy block titles by creating a block.tpl.php file and adding this code, or if the file already exists, modify the existing code:

  <div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
    <!-- <h2 class="title"><?php print $block->subject; ?></h2> -->
    <img src = "/path to/files/textimage/titles/<?php print $block->subject; ?>.jpg">
    <div class="content"><?php print $block->content; ?></div>
 </div>

Brad

BradM’s picture

Title: Text Image to generate Page Titles » this will generate all other titles (forum, blog, etc)

Hey, something I just discovered.

Edit page.tpl.php --

If you change this line:
<h1><?php print $title ?></h1>

To this:
<?php print fancy_title($title); print "<BR>"; ?>

It'll auto-change all titles on your pages.

Brad

deciphered’s picture

Status: Active » Closed (fixed)