Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Help with last post icon global tag

Quote Reply
Help with last post icon global tag
I have made a global to display the last post icon (if selected in post) to be displayed before the last post title in the category list.

Code:
TAG: last_icon

GLOBAL:

sub {
my $post_id = $_[0];
my $post_icon = $DB->table('Post')->select( ['post_icon'], { post_id => $post_id } )->fetchrow;
return $post_icon;
}

CALLED WITH: <img src="<%image_url%>/<%last_icon($forum_last_id)%>">

As there is no default icon the posts without icons show a "red X" box. I need help with an <%if .... statement.

Most that I have tried just ignore the icon and inserts blank.gif

Can anyone tell me what the missing XXXXX should be?

Code:
<%if XXXXX%><img src="<%image_url%>/<%last_icon($forum_last_id)%>">
<%else%>
<img src="<%image_url%>/blank.gif"><%endif%>

( Alternatively could I force a default icon to override "none"? )

Thanks
Quote Reply
Re: [MJB] Help with last post icon global tag In reply to
I've picked this up again and made a slight alteration:

Code:
<%if last_icon($forum_last_id)%>
<img src="<%image_url%>/<%last_icon($forum_last_id)%>" align="left">
<%else%>
<img src="<%image_url%>/icon1.gif" align="left">
<%endif%>

The <%if statement still doesn't work and every "last post" title now has icon1.gif infront of it.

I think I'm trying to incorporate a global into an <%if and it won't work that way. There's probably a very simple solution like incorporating the <%if into the global itself but I don't know how.

Crazy
Quote Reply
Re: [MJB] Help with last post icon global tag In reply to
You can do the check in the global itself (eg. $post ||= 'blank.gif') or in the template code (eg. <%set icon = last_icon($forum_last_id)%><img src="<%image_url%>/<%if icon%><%icon%><%else%>blank.gif<%endif%>">)

Adrian
Quote Reply
Re: [brewt] Help with last post icon global tag In reply to
Excellent!

Used the template code and it works fine.

Thanks for your input, much appreciated.

Wink