The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Turning a User Profile Field into a link
I would like my users to be able to enter their Twitter profile username like @username into a Single-Line Text Box. I was hoping I could make this username turn into a link on their profile that goes to (twitter.com/username) whatever they entered as their username. Any help would be very appreciated.
|
#2
|
|||
|
|||
Sure, that's easy -- just call the profile field in the link. Here's an example of one I use to create links to our wiki:
Code:
<a href="http://mysite/wiki/index.php/{vb:raw post.field109}"> |
#3
|
|||
|
|||
Thanks for the reply but could you shed a little more light on how to do that? I am brand new to vBulletin. I can figure it out but I'll need a little bit more help. Thank you!
|
#4
|
|||
|
|||
Start here:
https://www.vbulletin.com/forum/cont...-Profile-Field Once you've made your profile field, look at the field number -- then edit whichever template is the one you want it to appear in, using the {vb:raw post.fieldx} variable to display that field. |
#5
|
|||
|
|||
I'd like to bump this. I have a custom profile field -- "field7" -- which is a single-line text box where users enter the URL of their personal thread on my forum. I would like this to turn into a link. Which template do I add the HTML to? I tried adding this code to the userfield_textbox template, but it didn't work:
Code:
<a href="{vb:raw post.field7}"> If someone could verify that I'm using the right code and help me figure out where exactly I need to put this text in order to make field 7 turn into a link, I would really appreciate it! |
#6
|
|||
|
|||
I think you'd want something like:
Code:
<a href="{vb:raw post.field7}">{vb:raw post.field7}</a> But if you want it to show up on the profile page, I think you want to edit template memberinfo_profilefield and check $profilefield[profilefieldid] == 7. So something like: Code:
<vb:if condition="$profilefield[profilefieldid] == 7"> <a href="{vb:raw profilefield.value}">{vb:raw profilefield.value}</a> <vb:else /> {vb:raw profilefield.value} </vb:if> (the {vb:raw profilefield.value} is a line that already exists in the template, so you want to find that line and replace it with the above. |
#7
|
|||
|
|||
Oops, I posted this early this morning and I just noticed that it was wrong, you want to use {vb:raw profilefield.value} not {vb:raw post.field7}. I've fixed the post above.
|
#8
|
|||
|
|||
Thanks so much, kh99. I opened the memberinfo_profilefield template, which says this:
Code:
<dl> <vb:if condition="$show['profilefield_edit']"> <dt id="profilefield_title_{vb:raw profilefield.profilefieldid}" class="aboutme_left">{vb:raw profilefield.title}</dt> <dd id="profilefield_value_{vb:raw profilefield.profilefieldid}" class="aboutme_right"> {vb:raw profilefield.value} <script type="text/javascript"> <!-- vBulletin.register_control("vB_ProfilefieldEditor", "{vb:raw profilefield.profilefieldid}"); //--> </script> </dd> <vb:else /> <dt>{vb:raw profilefield.title}:</dt> <dd>{vb:raw profilefield.value}</dd> </vb:if> </dl> If I'm following correctly, you're saying I should replace the text above in red with this: Code:
<vb:if condition="$profilefield[profilefieldid] == 7"> <a href="{vb:raw profilefield.value}">{vb:raw profilefield.value}</a> <vb:else /> {vb:raw profilefield.value} </vb:if> ...and, strangely, it works to make field 7 into a hyperlink when a user is viewing their own profile in Edit mode, but when you click on "View your About Me as seen by everyone else," and when you view another user's profile, field 7 no longer appears as a hyperlink. So, instead, I tried replacing this other text in blue: Code:
<dl> <vb:if condition="$show['profilefield_edit']"> <dt id="profilefield_title_{vb:raw profilefield.profilefieldid}" class="aboutme_left">{vb:raw profilefield.title}</dt> <dd id="profilefield_value_{vb:raw profilefield.profilefieldid}" class="aboutme_right"> {vb:raw profilefield.value} <script type="text/javascript"> <!-- vBulletin.register_control("vB_ProfilefieldEditor", "{vb:raw profilefield.profilefieldid}"); //--> </script> </dd> <vb:else /> <dt>{vb:raw profilefield.title}:</dt> <dd>{vb:raw profilefield.value}</dd> </vb:if> </dl> ...and then field 7 started showing as a hyperlink in "as seen by everyone else" mode. Well, that's better, at least! Then I thought, why not just replace both the red and the blue text? Perhaps this is what you were getting at in your post, but if so, I totally missed it. So, my final code looks like this: Code:
<dl> <vb:if condition="$show['profilefield_edit']"> <dt id="profilefield_title_{vb:raw profilefield.profilefieldid}" class="aboutme_left">{vb:raw profilefield.title}</dt> <dd id="profilefield_value_{vb:raw profilefield.profilefieldid}" class="aboutme_right"> <vb:if condition="$profilefield[profilefieldid] == 7"> <a href="{vb:raw profilefield.value}" target="blank">{vb:raw profilefield.value}</a> <vb:else /> {vb:raw profilefield.value} </vb:if> <script type="text/javascript"> <!-- vBulletin.register_control("vB_ProfilefieldEditor", "{vb:raw profilefield.profilefieldid}"); //--> </script> </dd> <vb:else /> <dt>{vb:raw profilefield.title}:</dt> <dd><vb:if condition="$profilefield[profilefieldid] == 7"> <a href="{vb:raw profilefield.value}" target="blank">{vb:raw profilefield.value}</a> <vb:else /> {vb:raw profilefield.value} </vb:if></dd> </vb:if> </dl> ...and now field 7 appears as a hyperlink both in Edit mode and in "as seen by everyone else" mode. Woohoo! THANK YOU! |
#9
|
|||
|
|||
That wasn't what I was getting at, I didn't realize it was using different code for the different pages. Anyway, I'm glad you got it figured out, good work, and thanks for posting the result.
|
#10
|
||||
|
||||
<a href="https://vborg.vbsupport.ru/showthread.php?t=290163" target="_blank">e360 User's Social Links</a>
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|