View Full Version : do not display certain attachments.
Bernd
05-14-2006, 10:34 AM
I'm trying to write a simple if statement to disallow the forum from displaying image attachments with the name "thumb.jpg".
$attachment[filename] returns the name of the image, so that's working just fine. However, the if statement below displays the text thumbnail at all times. What am I doing wrong here? (the code below is stated in one of the templates). I've just started looking into php ;)
<if $attachment[filename]="thumb.jpg">
thumbnail
</if>
Alan @ CIT
05-14-2006, 10:39 AM
Try:
<if $attachment[filename] == "thumb.jpg">
thunbnail
</if>
For comparison, you need to use 2 equals signs (==). 1 will just set $attachment[filename] to "thumb.jpg" instead of comparing it.
Thanks,
ALan.
Bernd
05-14-2006, 10:53 AM
I've tried that and it still returns thumbnail no matter what.
Are statements somehow limited in templates? I haven't seen any if statements in other template files except for "if condition etc".
Alan @ CIT
05-14-2006, 11:00 AM
What template are you editing, and where are you putting the edit?
Bernd
05-14-2006, 11:03 AM
It's a template from a custom hack, but it contains the following
$attachment[filename]
<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&d=$attachment[dateline]"<if condition="$show['newwindow']"> target="_blank"</if>>
<img class="thumbnail" src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&stc=1&thumb=0&d=$attachment[thumbnail_dateline]" border="0" align="center"></a>
<if condition="$show['br']"><br /><br /></if>
I added $attachment[filename] in the above code to see if it pulls the file names of the attached files, and it does...so the if statement you provided should work? Don't no why it doesn't.
Alan @ CIT
05-14-2006, 11:03 AM
ooops, sorry - type on my part. It should look something like:
<if condition="$attachment[filename]==thumb.jpg">
thunbnail
</if>
Take a look at the template conditionals section here http://www.vbulletin.com/docs/html/ if that doesn't work.
Bernd
05-14-2006, 11:13 AM
Thanks for your help.
<if condition="$attachment[filename] == "thumb.jpg"">
turned out to be the correct if statement :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.