PDA

View Full Version : Need help with this


veenuisthebest
11-22-2008, 12:44 PM
Hii,

I used HTML in Forum title field to display a image. (I must use it in title and not in description). Say I used this code:-

<img src="images/forumlogos/8.gif" align="left" border="0" alt="" hspace="5" />Forum title


It works just perfect and I am able to achieve what i want. BUT one thing I don't like is that the image is even displaying in the category strip (in the tcat) while viewing that forum, which is stretching it and making it look very bad.

SO, how do I block the HTML part to show in the tcat? and allow only the text i.e. Forum title. There's got to be some way to do it.

Thank you

ReCom
11-22-2008, 01:01 PM
How about using plugin to inject the img tag into the output instead of inserting the tag in forum title? Or even customize the specific forum listing template. That way the image will appear exactly where you want it to be instead of wherever the forum title is displayed (one can never know all the places the forum title is displayed -- archives, RSS, thread subscription emails? *shivers*) ...

veenuisthebest
11-22-2008, 01:25 PM
Thanks for your reply recom!

But I need more info please. Give me some idea of how the plugin code would look like and what hooks to use, i am new to this!

Thanks

ReCom
11-22-2008, 01:46 PM
Add a plugin with hook location: forumbit_display

The code: $forum['title'] = '<img src="images/forumlogos/'.$forum['forumid'].'.gif" onerror="this.style.display=\'none\';" /> '.$forum['title'];

Save the plugin.

Then upload the forum logos into your images/forumlogos directory, with each logo named after the forumid (e.g. if the forumid is 18 then the logo is named 18.gif)

Set the plugin as active.

(the img tag I included above is special since it automatically handles situations where the logo files are missing by hiding itself)

veenuisthebest
11-22-2008, 02:35 PM
thanks, but I could achieve exactly the same thing editing forumhome_forumbit_level2_post template. But plugin thing saved my edit ;)

I'm getting xhtml validation errors with onerror attribute. And the img tag still exists for all forums where logo files are missing. How do I stop injecting img tag on forums that does not have logo file?

Thanks

--------------- Added 1227379492 at 1227379492 ---------------

alright, I checked for existence of file this way.

$filename = 'images/forumlogos/'. $forum[forumid].'.gif';

if (file_exists($filename)) {
$forum['title'] = '<img src="images/forumlogos/'.$forum['forumid'].'.gif" /> '.$forum['title'];
}

Thanks