vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Turning a User Profile Field into a link (https://vborg.vbsupport.ru/showthread.php?t=293656)

ThatsDank 01-06-2013 08:48 PM

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.

grey_goose 01-10-2013 01:36 AM

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}">

ThatsDank 01-10-2013 09:23 PM

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!

grey_goose 01-11-2013 02:45 AM

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.

msmayz 06-04-2014 06:31 AM

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!

kh99 06-04-2014 08:50 AM

I think you'd want something like:
Code:

<a href="{vb:raw post.field7}">{vb:raw post.field7}</a>
if you were inserting it in postbit, that is.

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.

kh99 06-04-2014 09:33 PM

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.

msmayz 06-05-2014 03:41 AM

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! :D

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!

kh99 06-05-2014 07:28 AM

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.

Elite_360_ 06-07-2014 07:43 AM

<a href="https://vborg.vbsupport.ru/showthread.php?t=290163" target="_blank">e360 User's Social Links</a>


All times are GMT. The time now is 10:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01080 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete