Hello,
I am currently upgrading my site and i came to a point where i wanted to use images for the block titles.
Here is the solution that i came up with:
In theme.php file for your theme i modified the themesidebox function to be something like:
function themesidebox
($block) {$cp =
4;
if($block['position'] ==
'c') { echo "<table width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
if (!
empty($block['title'])) { echo "<tr>\n" .
"<td align=\"center\" valign=\"top\">\n" .
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">\n" .
"<tr>\n" .
"<td class=\"pn-blocktitle\">$block[title]</td>\n" .
"</tr>\n" .
"</table>\n" .
"</td>\n" .
"</tr>\n" .
"<tr bgcolor=\"$GLOBALS[sepcolor]\">\n" .
"<td><img src=\"themes/$GLOBALS[thename]/images/pix-t.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\"></td>\n" .
"</tr>\n" .
"<tr>\n";
} echo "<td align=\"left\" valign=\"top\" class=\"pn-normal\">$block[content]</td>\n" .
"</tr>\n" .
"</table>\n";
}else { echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
if (!
empty($block['title'])) { $bimage =
str_replace(" ",
"",
$block[title
]);
// here we remove the white spaces $bimage =
strtolower($bimage);
if(is_file("images/blocks/titles/".
$bimage.
".gif")) { //here we check is the file exists $block[title
] =
"<img src=\"images/blocks/titles/$bimage.gif\">";
// if it exists we tell it to use the image $cp =
0;
// and we set the cellpadding to 0 not to leave spaces around the image } echo "<tr>\n" .
"<td align=\"center\" valign=\"top\">\n" .
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"$cp\">\n" .
"<tr>\n" .
"<td class=\"pn-blocktitle\">$block[title]</td>\n" .
"</tr>\n" .
"</table>\n" .
"</td>\n" .
"</tr>\n" .
"<tr>\n";
} echo "<td align=\"left\" valign=\"top\">$block[content]</td>\n" .
"</tr>\n" .
"</table>\n";
}}
So basically what it does is if it is not a center blocks it checks in the images/blocks/titles/ directory to see if there is a GIF file for the block title. If there is one it prints the picture if there is none then it just prints the normal block title.
The way to name your image file is:
If your block title is My Block then script will remove the white spaces which will give us MyBlock and it will change everything to lower case which will give us myblock. And finally it adds the GIF extention to myblock which gives us myblock.gif.
So in your images/blocks/titles/ directory if you have myblock.gif, it will print the image if that file does not exist then it will just print the block title.
Some of you might have to put a @ sign before the is_file function to make it look like @is_file as it might throw error messages sometimes.
Good luck.