View Full Version : Quick Question
dudeness3
06-01-2006, 02:40 AM
I have a Pokemon forum and I want to put a dropdown list in "Edit Profile" listing 386 names, when a user chooses a name, the sprite of that chosen name appears in their postbit, representing what their favorite pokemon is.
can this be done?
Lea Verou
06-01-2006, 03:51 AM
Yes it can.
dudeness3
06-01-2006, 04:04 AM
thats great, at least i know it can be done, thank you
checkmail
06-01-2006, 04:06 AM
Atleast he didn't lie that it was quick
antialiasis
06-01-2006, 04:13 AM
Yes, it can be done. (Admittedly, I highly don't recommend putting the sprite in the postbit - too many images in the postbit can be distracting and annoying. But each to his own.)
First, if you really want to go through with the sprites thing, you'll have to get all the Pok?mon sprites with their names as their filenames somehow. You can look around yourself (or, better yet, you may have them already or know a place where you can get them), but if you don't have them and can't find any, you can just ask me to zip them for you. Just upload them in a special folder called sprites or something under images at the forums.
Now go to Admin CP -> User Profile Fields -> Add New User Profile Field
As Profile Field Type, choose "Single-selection Menu"
Apply these settings (modify at will, of course):
Title: Favorite Pok?mon
Description: Pick your favorite Pok?mon.
Set Default: None
Display Order: (leave it as it is)
Field Required: (whichever you want)
Field Editable by User: Yes
Private Field: No (unless you don't want it shown in people's profile)
Field Searchable on Members List: (whichever you want)
Show on Members List: (whichever you want)
(leave all the "Optional Input" stuff like it is)
Display Page: Edit Profile
Now, for the options, you would normally have to type out the names of all 386, but as it happens that I'm also a Pok?mon fan and have too much time on my hands, I have a Pok?mon list generator (http://www.dragonflycave.com/list.aspx) on my website. Just enter %[name]% into the field, press the Submit button, copy everything in the textarea, and paste it into the options field.
Now press Save at the bottom of the user profile field manager. It should bring you back to the list of user profile fields. Find the field you just added, remember the "name" (which will be something in the direction of field123), and go to the Style Manager under Styles and Templates on your Admin CP menu. From there, select each of your styles in order, go to Edit Templates, and edit either postbit or postbit_legacy (located under "Postbit templates"), depending on which you are using.
Now, just find the appropriate place in the code, and add this:
<if condition="$post['field123']"><img src="images/sprites/$post[field123].gif" alt="$post[field123]" /></if>
Of course, if your sprites have some other extension than .gif, such as .png, change the extension in the code accordingly, and replace field123 in all three places with the field name of your favorite Pok?mon field.
And if you did all this correctly, it should show up for all users who have specified a favorite Pok?mon.
Lea Verou
06-01-2006, 04:19 AM
He can disable avatars and put that image instead. So he wont have many images.
In fact I think it's a great idea for a pokemon forum.
Now, just find the appropriate place in the code, and add this:
<if condition="$vbulletin->userinfo['field123']"><img src="images/sprites/$bbuserinfo[field123].gif" alt="$bbuserinfo[field123]" /></if>
I don't think that would work. AFAIK it would be:
<if condition="$post['field123']"><img src="images/sprites/$post[field123].gif" alt="$post[field123]" /></if>
Remember, we are talking about the postbit.
antialiasis
06-01-2006, 02:21 PM
Yeah, slip-up. Sorry. Should be what Michelle said.
Shows me not to attempt to write tutorials at five in the morning...
dudeness3
06-06-2006, 02:09 AM
wow thanks, thats perfect, and btw, I had all the sprites uploaded anyway, but thanks so much, and I'm glad I found a pokefan :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.