View Full Version : Displaying Images in Profile Block instead of Text?
gorentals
08-13-2009, 03:34 PM
Lets say I have 3 Custom Fields. Game1, Game 2, Game 3
And I want my members to enter codes for each of the 3 games.
Anyone know how to accomplish this?
Lynne
08-13-2009, 04:01 PM
I think there is an article in the articles forums on how to add a block to the profile/member.php page. Have you looked there?
gorentals
08-13-2009, 07:10 PM
THanks Lynne. I did find this https://vborg.vbsupport.ru/showthread.php?t=203775
I am able to create the fields, and the block, but I don't know the code on how to display images based on a field.
So lets say I have field 1: text (to be used as the alt text of graphic)
Then in profile Block I would like to display a graphic that represents Field 1.
Does this make sense to anyone?
Thanks for your time
HMBeaty
08-13-2009, 07:18 PM
You can do it how I did mine and create an if conditional for each one by using a code like this...
<if condition="$post[fieldxx]">
<img src="$stylevar[imgdir_misc]/$post[fieldxx].gif" alt="" />
</if>
And change xx to your profile field number. You must also have the image named exactly how the profile field is written. For example, if you have an option that says "Marine Corps", you must name your image "Marine Corps.gif" or whatever extension you want to use (.gif, .png, etc.)
Hope that helps you out :)
Lynne
08-13-2009, 08:42 PM
See if what Brooks posted is what you wanted. You may want to add something in where it says alt="". Like alt="$post[fieldxx]" ? It's hard to tell without actual examples of what you will have in the fields.
gorentals
08-13-2009, 11:50 PM
Thank you guys for helping me out. Here is my code in the Memberinfo Template at the bottom: I am also on Vbulletin 3.8.3
<div id="sidebar_container">
<!-- sidebar -->
$template_hook[profile_right_first]
$blocks[stats_mini]
<!--new block-->
<!-- $id -->
<div id="$id" class="tborder content_block">
<h4 class="thead block_title">
<a href="#top" class="collapse_gadget" onclick="return toggle_collapse('$id')"><img id="collapseimg_$id" src="$stylevar[imgdir_button]/collapse_generic{$vbcollapse['collapseimg_'.$id]}.gif" alt="" border="0" /></a>
<a name="$id"></a>
<span class="block_name">Codes</span>
</h4>
<div class="block_content" id="collapseobj_$id" style="{$vbcollapse['collapseobj_'.$id]}"><div class="alt1 smallfont block_row block_footer">
<if condition="$post[field15]">
<img src="$stylevar[imgdir_misc]/$post[field15].png" alt="$post[field15]" />
</if>
</div></div>
</div>
<!-- / $id -->
<!--new block-->
$template_hook[profile_right_mini]
$blocks[friends_mini]
$blocks[youtube]
$blocks[albums]
$template_hook[profile_right_album]
$blocks[groups]
$blocks[visitors]
$template_hook[profile_right_last]
<!-- / sidebar -->
</div>
<!-- end usercss -->
</div>
$footer
</body>
</html>
Ok I can see the Codes Block, but nothing shows. I have a Field called mk and its field15. What is entered in that field is just numbers. Is my code wrong? thanks for any assistance.
Lynne
08-14-2009, 12:10 AM
The code you wrote is looking for image files named 2322.png or 222.png or whatever-the-number-is.png. If you always want it to show mk.png, then you need to change $post[field15].png to mk.png
gorentals
08-14-2009, 12:49 AM
Ok I changed the code. No matter what I have in Field15 the graphic never shows up in my codes block. Is there something wrong with my block code? The field is just a single text field. Logically it looks like it should display the image. I am at a loss as to why nothing displays.
HMBeaty
08-14-2009, 01:36 AM
Ok I can see the Codes Block, but nothing shows. I have a Field called mk and its field15. What is entered in that field is just number codes like... 2322-2222-2223-2322. I also created a file called mk.png to show as the graphic in the block. Is my code wrong? thanks for any assistance.
If you have 2322-2222-2223-2322 entered in the field, your image needs to be named 2322-2222-2223-2322.png or .gif or whatever
Lynne
08-14-2009, 01:37 AM
I should have noticed... you can't use $post right there, it's should be $userinfo.
HMBeaty
08-14-2009, 01:41 AM
AH! Yes! Since this is in the memberinfo templates, your code should be..
<if condition="$userinfo[field15]">
<img src="$stylevar[imgdir_misc]/$userinfo[field15].png" alt="$userinfo[field15]" />
</if>
gorentals
08-14-2009, 02:05 AM
Thank you Brooks and Lynne that was it!!! Kudos!
HMBeaty
08-14-2009, 02:15 AM
Not a problem :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.