Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2008, 11:49 AM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Linkable Custom Profile Fields

I have a custom profile field appearing in a custom template as $userinfo[field32], I want the output to be linkable. However the content is a list of items seperated by commas.

Basically I am looking to do something similar to this hack here, but for VBulletin 3.7 and applied to a custom template with custom profile fields:
https://vborg.vbsupport.ru/showthread.php?t=148705

So i'd like each item seperately linkable to the memberlist search. Here is the code I have which doesn't seem to be working:

Code:
if ($userinfo['field32'] != '')  
{ 
        $links = explode ("\n", $userinfo['field32']); 
        $output = array(); 
        foreach ($links as $link) 
        { 
                  $link = trim($link); 
                  if (!empty($link)) 
                  { 
                            $ouput[] = '<a href="' . $link . '">' . $link . '</a>'; 
                  } 
        } 
        $userinfo['field32'] = implode('<br />', $output); 
}
Also, if made functional. How would I make it work for more than 1 profile field? An Array I presume?
Reply With Quote
  #2  
Old 04-29-2008, 08:43 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm afraid I can't give you an exact answer, because I've got a similar question as yours.
However, this is working:
https://vborg.vbsupport.ru/showthread.php?t=161271
Reply With Quote
  #3  
Old 04-29-2008, 09:04 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply! I wasn't aware of your thread and I've done some pretty extensive searching. Well for some odd reason it simply doesn't react at all? I must be doing something wrong, and I'm sure it's something simple. And I did correct the typo in the code as well.

The content I would like to be linked is inside a custom template which is displayed on my profile page through this code:
$userinfo[field13]


Here is my plugin:
Name: Linkable Custom Profile Fields
Location: Member_complete (also tried member_start)
Execution Order: 1

Code:
if ($profilefield['value'] != '' AND $profilefield[profilefieldid] == 13) 
{
        $links = explode ("\n", $profilefield['value']);
        $output = array();
        foreach ($links as $link)
        {
                  $link = trim($link);
                  if (!empty($link))
                  {
                            $output[] = '<a href="' . $link . '">' . $link . '</a>';
                  }
        }
        $profilefield['value'] = implode('<br />', $output);
}
Any help would be appreciated.
Reply With Quote
  #4  
Old 04-29-2008, 09:23 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GameWizard View Post
The content I would like to be linked is inside a custom template which is displayed on my profile page through this code:
$userinfo[field13]
I'm afraid this was my question aswell, and I can't help you with that
Reply With Quote
  #5  
Old 04-29-2008, 10:52 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I played around with the code and managed to get this to actually work:

Code:
if ($userinfo[field13] != '')
{
        $links = explode (",", $userinfo[field13]);
        $output = array();
        foreach ($links as $link)
        {
                  $link = trim($link);
                  if (!empty($link))
                  {
                            $output[] = '<a href="' . $link . '">' . $link . '</a>';
                  }
        } 
        $userinfo[field13] = implode(', ', $output);
}
The user inputed "English, French, Russian" and it shows up as "English, French, Russian" as separate links which is what I want.

HOWEVER, it does not obviously link to the proper area inside my memberlist.php file which is what I need. It just links to mydomain.com/English.

Here is the code from another hack which seems should work, but I don't know how to adapt it to work with my current code:
https://vborg.vbsupport.ru/showthread.php?p=1462022
Code:
if ($profilefield['value'] != '')
{
    $linkedfields = explode("|", $vbulletin->options['profilefieldtagslist']);
     
    if (in_array($profilefield['profilefieldid'], $linkedfields))
    {
        if ($profilefield['type'] == 'input' OR $profilefield['type'] == 'textarea')
        {
            $fieldvalues = explode(",", $profilefield['value']);
            $profilefield['value'] = '';
          
            foreach ($fieldvalues as $fieldvalue)
            {
                $profilefield['value'].= '<a href="' .$vbulletin->options['bburl']. '/memberlist.php?' .$vbulletin->session->vars['sessionurl']. 'do=getall&amp;field' .$profilefield[profilefieldid]. '=' .trim($fieldvalue). '">' .$fieldvalue. '</a>, ';
            }
            
            $profilefield['value']= substr_replace($profilefield['value'],'',-2);
            $userinfo['field' . $profilefield[profilefieldid]] = $profilefield['value'];
        }
Based on this I just need the linkable part incorporated into the code, but he uses things such as $fieldvalues which I am unsure of how to incorporate. Any help would be appreciated!

==========UPDATE=============

I managed to get it working perfectly!

Code:
if ($userinfo[field13] != '')
{
        $links = explode (",", $userinfo[field13]);
        $output = array();
        foreach ($links as $link)
        {
                  $link = trim($link);
                  if (!empty($link))
                  {
                            $output[] = '<a href="' .$vbulletin->options['bburl']. '/memberlist.php?' .$vbulletin->session->vars['sessionurl']. 'do=getall&amp;field13=' .trim($link). '">' . $link . '</a>';
                  }
        } 
        $userinfo[field13] = implode(', ', $output);
}
Took me some time, but i figured out how to transfer the code over. I had to hard code the Field ID though, so right now I'm in the process of looking up how to setup a proper PHP Array to allow for multiple profile fields to work.
Reply With Quote
  #6  
Old 04-30-2008, 10:21 AM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks GameWizard, you're amazing!
I've never thought about giving it the member_complete location before.
Reply With Quote
  #7  
Old 04-30-2008, 12:33 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What I've found is that the code works great for any Single-Line and Multi-Line text box. However, I've had trouble converting the code for Multiple/Single menu. It keeps outputting errors which either means that the code is wrong, or the way I'm converting it is incorrect. In any case, I will post the code below in case someone with a more skilled php brain is willing to help:

Here is my functional code once again which applies to Single-Line and Multi-Line text box:
Code:
if ($userinfo[field12] != '')
{
        $links = explode (",", $userinfo[field12]);
        $output = array();
        foreach ($links as $link)
        {
                  $link = trim($link);
                  if (!empty($link))
                  {
                            $output[] = '<a href="' .$vbulletin->options['bburl']. '/memberlist.php?' .$vbulletin->session->vars['sessionurl']. 'do=getall&amp;field12=' .trim($link). '">' . $link . '</a>';
                  }
        } 
        $userinfo[field12] = implode(', ', $output);
}

Here is the code included that I need converted into a similar format as above:
Code:
            $data = unserialize($profilefield['data']);
            $fieldvalues = explode(",", $profilefield['value']);
            $profilefield['value'] = '';

            foreach ($data as $key => $value)
            {
                $key++;
                foreach ($fieldvalues as $key2 => $value2)
                {
                    if (trim($value) == trim($value2))
                    {
                        $profilefield['value'] .= '<a href="' .$vbulletin->options['bburl']. '/memberlist.php?' .$vbulletin->session->vars['sessionurl']. 'do=getall&amp;field' .$profilefield[profilefieldid]. '=' .$key. '">' .$value2. '</a>, ';
                    }
                }
            }
            
            $profilefield['value']= substr_replace($profilefield['value'],'',-2);
            $userinfo['field' . $profilefield[profilefieldid]] = $profilefield['value'];
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:04 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08719 seconds
  • Memory Usage 2,235KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete