View Full Version : Multiple-Choice userfield->Postbit options?
MTGDarkness
07-08-2009, 01:09 PM
My forum has a clans section. Each clan has their own emblem, banner, ideals, etc. However, the clans section has sort of been lacking lately. And the idea came up to have it so that you could select your clan over your UCP and then have an icon and link to it show up in your postbit.
I've seen this before on a forum called "smashboards" where you can select which character you use in the game and then it shows up in the postbit. I PM'd the admin there and he gave me this:
"It's basically just a custom field, a small plugin, and a template adjustment. The plugin takes the custom field and generates the URL of the postbit icon, and the template just includes the image in the postbit."
However, I don't really know how to do this... Help?
Lynne
07-08-2009, 02:02 PM
It sounds like he is saying he added a new field to the database (although why not use a User Profile Field?) and then has a plugin that take the result of that field and creates a url based on it (if TheField=1, then the url is xxxxx, if TheField=2, then the url is yyyy) and the template just spits this out.
I don't know why you wouldn't use a User Profile Field for this. Then, create a plugin to spit out a url based on that field.
The best thing to do is find another modification that does something with a (multiple-choice) User Profile Field and see how they did things and modify it for your own use. I think there was a country flag mod out there that may be setup like this. Play with it on a test site.
MTGDarkness
07-08-2009, 04:31 PM
No, he is using a user profile field. That's what I meant. I'll see what I can do...
--------------- Added 1247083427 at 1247083427 ---------------
Is it possible to do it over template variables?
Say, something like this:
<if condition="$post[fieldX1]=something here?">stuff</if>
If so, what would something here be?
Lynne
07-08-2009, 10:25 PM
I don't know what you mean by "do it over template variables". You can do a condition in the template, if you want. As for the something here.... um, if you are using a multiple-choice textbox, you can see how to do that here - http://www.vbulletin.com/forum/showthread.php?t=108785 (see post 2).
MTGDarkness
07-09-2009, 03:55 AM
On a Single-Selection Menu with following options:
none
[Izzet]
[Soundtrack]
[Aesir]
[The Banana]
This is the code I'm using:
<if condition="$post['field9'] & 2">
<!-- Izzet --> <a href="http://forums.mtgdarkness.com/showthread.php?t=21665"><img src="http://img515.imageshack.us/img515/4530/izzeticon.png" alt="[Izzet]" /></a>
</if>
<if condition="$post['field9'] & 4">
<!-- Soundtrack -->
</if>
<if condition="$post['field9'] & 8">
<!-- aesir -->
</if>
<if condition="$post['field9'] & 16">
<!-- banana -->
</if>
It isn't working. >.< Nothing shows up in the source code regardless what you select.
What's wrong with it?
Lynne
07-09-2009, 02:31 PM
Right now, nothing should show up unless they picked the option Izzet. Did you put the code in the correct postbit - which one? You didn't say where you put it at all, which makes it difficult to guess what may be wrong. What lines are before it and after it (just three or four lines should be fine)? Is anything showing in the page source?
MTGDarkness
07-09-2009, 03:30 PM
I put it in its own template, which I then linked to in the postbit. (I tested it by putting a non-conditional comment in there which does appear correctly).
Why shouldn't anything happen unless they've chosen izzet? Or do you mean nothing except comments? Even the izzet aren't showing their icon... The lines before and after are these:
<if condition="$show['popups']"><script type="text/javascript"> vbrep_register("$post[postid]")</script></if>
</if>
$clans
<if condition="$show['infractionlink']"><a href="infraction.php?$session[sessionurl]do=report&p=$post[postid]" rel="nofollow"><img class="inlineimg" src="$stylevar[imgdir_button]/infraction.gif" alt="<phrase 1="$post[username]">$vbphrase[add_infraction_for_x]</phrase>"
Where $clans is the template variable (I set up the plugins for that right as well) leading to the code posted above.
Lynne
07-09-2009, 06:18 PM
Try putting the code directly into the template and get it to work. Then see about putting it into it's own template and evaling it in a plugin (hook location and exact code? You should give all information when saying something isn't working.).
MTGDarkness
07-09-2009, 07:12 PM
No, it works. What I did was put the following snippet of code outside of all the conditionals in the template:
<!-- Clans -- >
And when I looked in the source code, that showed up in the postbit. The problem really can only be with the conditionals.
Lynne
07-09-2009, 10:20 PM
I thought you said you were doing a multiple choice userfield? The method/conditions you are using are for a multiple choice userfield, not a single selection field. You would use the normal method (a basic comparison) for a single selection field.
MTGDarkness
07-10-2009, 03:07 AM
O.o
Okay. How would that be set up?
I'm stupid. Got it.
<if condition="$post['field9']='[Izzet]'">
<!-- Izzet <a href="http://forums.mtgdarkness.com/showthread.php?t=21665"><img src="http://img515.imageshack.us/img515/4530/izzeticon.png" alt="[Izzet]" /></a> -->
</if>
<if condition="$post['field9']='[Soundtrack]'">
<!-- Soundtrack -->
</if>
<if condition="$post['field9']='[Aesir]'">
<!-- aesir -->
</if>
<if condition="$post['field9']='[The Banana]'">
<!-- banana -->
</if>
<!-- clans -->
Also tried this:
<if condition="$post['field9']=1">
<!-- Izzet <a href="http://forums.mtgdarkness.com/showthread.php?t=21665"><img src="http://img515.imageshack.us/img515/4530/izzeticon.png" alt="[Izzet]" /></a> -->
</if>
<if condition="$post['field9']=2">
<!-- Soundtrack -->
</if>
<if condition="$post['field9']=3">
<!-- aesir -->
</if>
<if condition="$post['field9']=4">
<!-- banana -->
</if>
<!-- clans -->
(corresponding by the places in the list)
Everything shows up regardless of what they have selected.
Lynne
07-10-2009, 03:39 PM
Take a look at other condition statements in your templates and you'll see the you don't use "=", you use "==". Try that.
MTGDarkness
07-10-2009, 03:57 PM
Oh right. I'm silly. That worked. Thanks. :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.