View Full Version : Include image of a category
unnpro
04-12-2007, 08:25 AM
Hi,
how can I include an image in a category only if it exits on the server?
Something like:
ob_start();
if (file_exists("images/categories/cat_".$forumid.".jpg")) {
$includeimgcat = "<img src=\"images/categories/cat_".$forumid.".jpg\" width=\"85\" height=\"85\" alt=\"\" style=\"vertical-align: middle;\" />";
} else {
$includeimgcat = "";
}
ob_end_clean();
I tried to write a plugin and edit forumhome_forumbit_level1_nopost template without any result :(
TIA
Dismounted
04-12-2007, 08:29 AM
Does $forumid exist?
unnpro
04-12-2007, 08:46 AM
Does $forumid exist?
I think so .. :erm:
i tried to put in the template (forumhome_forumbit_level1_nopost)
<img src="images/categories/cat_$forumid.jpg" width="85" height="85" alt="" /> and it works correctly but obviously if the image doesn't exists I see many red X .. so I'm searching for a way to display it only when it exists.
Dismounted
04-12-2007, 09:16 AM
Which hook are you putting it in?
unnpro
04-12-2007, 09:21 AM
global_start .. also forumhome_start doesn't work
Dismounted
04-12-2007, 11:14 AM
Get rid of ob_start(); and ob_end_clean();
And try forumhome_complete.
unnpro
04-12-2007, 11:24 AM
Nothing happens :(
Dismounted
04-12-2007, 11:30 AM
What do you put in your template?
unnpro
04-12-2007, 11:32 AM
only this: $includeimgcat
Dismounted
04-12-2007, 11:44 AM
Try this in your plugin:
if (file_exists(DIR . 'images/categories/cat_' . $forumid . '.jpg'))
{
$includeimgcat = '<img src="images/categories/cat_' . $forumid . '.jpg" width="85" height="85" alt="" style="vertical-align: middle;" />';
}
else
{
$includeimgcat = '';
}
unnpro
04-12-2007, 11:53 AM
Nothing!
I made a test:
Plugin:
$includeimgcat = "teststamp"
Hook: forumhome_complete or forumhome_start or global_start
.. "teststamp" still not visibile in any category.
Thank you very much for your support!
Dismounted
04-12-2007, 12:05 PM
Can you post up your template?
unnpro
04-12-2007, 12:07 PM
forumhome_forumbit_level1_nopost
<tbody>
<tr>
<td class="tcat" colspan="<if condition="$vboptions[showmoderatorcolumn]">6<else />5</if>">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumbit_$forumid')"><img id="collapseimg_forumbit_$forumid" src="$stylevar[imgdir_button]/collapse_tcat{$collapseimg_forumid}.gif" alt="" border="0" /></a>
$includeimgcat
<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
<if condition="$show['subforums']"><div class="smallfont"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
</tr>
</tbody>
<if condition="$childforumbits">
<tbody id="collapseobj_forumbit_$forumid" style="{$collapseobj_forumid}">
$childforumbits
</tbody>
</if>
unnpro
04-18-2007, 01:11 PM
Up! :(
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.