Here I was trying to come up with this hack tonight, with not much luck. But after a search here, I realized I posted the same hack a couple of years ago under my old account (BradM)! I think I've lost some brain cells.
Anyway, I'm using XOOPS 2.0.16 and here's how to implement this old hack. Of course, back up the necessary files before modifying them!!
Step 1: edit /class/theme_blocks.phpIn
function buildBlock, just before the line
$block = array(, add the following code:
/* hack to auto-replace block titles with graphics */
// get the block title
$imgttl = $xobject->getVar( 'title' );
// replace spaces with underscores
$imgttl = str_replace(" ", "_", $imgttl);
// remove non-alphanumeric characters
$imgttl = preg_replace("(W)", "", $imgttl);
// convert to lower case
$imgttl = mb_convert_case($imgttl, MB_CASE_LOWER, "UTF-8");
// append image format
$imgttl = $imgttl.".gif";
// build paths
$imgpath = XOOPS_THEME_PATH.'/THEMEDIR/images/'.$imgttl;
$imgurl = XOOPS_THEME_URL.'/THEMEDIR/images/'.$imgttl;
// check for file
if (file_exists($imgpath)) {
$ttl_img = $imgurl;
}
else { $ttl_img = ""; }
/* end hack */
Here I'm using the path/url to a single theme directory ("THEMEDIR"). There must be a way to stick a XOOPS variable in here to make this applicable to all themes, but I don't know what it is.
Next, under
'lastmod' => $xobject->getVar( 'last_modified' ), add the following line:
'ttl_img' => $ttl_img,
Step 2: edit /themes/THEMEDIR/theme.htmlPut the following code where ever you would like to activate this switch. I only have it functioning on the right-hand column, so I've put this code where the right-hand blocks are generated. You need to replace
<{$block.title}> with the following:
<{if $block.ttl_img}>
<img src="<{$block.ttl_img}>" alt="<{$block.title}>" title="<{$block.title}>">
<{else}>
<{$block.title}>
<{/if}>
Step 3: upload your title graphics (in GIF format, all lower case) into /themes/THEMEDIR/images/.
Name them to match your titles, replacing spaces with underscores. For example, "User Menu" becomes "user_menu.gif". If the script can't find the file, it'll just add the text version.
That should do it. For some reason, this doesn't work on anything with an apostrophe (such as "Who's Online") -- and I cannot figure out why. I think XOOPS converts the apostrophe to unicode (or whatever it's called) so maybe that's why?
Brad