The Arcive of vBulletin Modifications Site. |
|
|
#1
|
||||
|
||||
|
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);
}
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
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);
}
|
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
||||
|
||||
|
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);
}
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&field' .$profilefield[profilefieldid]. '=' .trim($fieldvalue). '">' .$fieldvalue. '</a>, ';
}
$profilefield['value']= substr_replace($profilefield['value'],'',-2);
$userinfo['field' . $profilefield[profilefieldid]] = $profilefield['value'];
}
==========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&field13=' .trim($link). '">' . $link . '</a>';
}
}
$userinfo[field13] = implode(', ', $output);
}
|
|
#6
|
||||
|
||||
|
Thanks GameWizard, you're amazing!
I've never thought about giving it the member_complete location before. |
|
#7
|
||||
|
||||
|
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&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&field' .$profilefield[profilefieldid]. '=' .$key. '">' .$value2. '</a>, ';
}
}
}
$profilefield['value']= substr_replace($profilefield['value'],'',-2);
$userinfo['field' . $profilefield[profilefieldid]] = $profilefield['value'];
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|