View Full Version : Make other Profile fields parse as URLs?
Threshold
06-03-2003, 07:01 PM
The homepage profile field automatically parses as a URL.
On my site, I have two profile fields that would be dramatically improved if they were automatically treated as URLs (they are entries where a player can put a link to a RL picture and a character picture).
Is there a way to do this?
Thanks!
filburt1
06-03-2003, 07:03 PM
If they're just URLs, just edit the appropriate templates to include <a> tags...
Threshold
06-03-2003, 07:14 PM
I don't want *ALL* of the profile fields to be parsed as URLs.
For example, user profiles on my vBulletin have 6 required fields and 9 optional fields.
1 required field is email address, the other 5 are plain text.
Of the optional fields, 1 is a URL (homepage), 1 is signature, 1 is birthday, 1 is custom user text, and the other 5 are plain text.
I want 2 of those last 5 to be parsed as URLs, rather than plain text.
Unless I am missing something, the template just parses through a loop and treats them all the same, thus I cannot edit each individual one. Or am I missing something and not remembering or understanding correctly how the profile template works?
The two fields I want treated as URLs are called "Your Real Life Picture" and "Your Character's Picture."
I just used the Template Search function to look for those, and the search turned up nothing.
Am I just not understanding the way the template functions for parsing the user profile fields?
Threshold
06-03-2003, 07:29 PM
Ok, from further reading through the various files, everywhere the custom fields are handled (either for changing them or for viewing them), the code always says this:
$customfields
However, I cannot find where it is that I can edit that.
I have done numerous searches to no avail. :(
Boofo
06-03-2003, 07:32 PM
Look in functions.php for profile[fieldx].
Be sure to replace the x with the profile field number you are looking for.
Threshold
06-03-2003, 07:35 PM
Even further investigation has found that this is the template that handles the parsing of the custom fields:
getinfo_customfields
<tr>
<td bgcolor="$backcolor"><normalfont><b>$profilefield[title]</b></normalfont></td>
<td bgcolor="$backcolor"><normalfont>$profilefield[value] </normalfont></td>
</tr>
To test this, I changed that code to this:
<tr>
<td bgcolor="$backcolor"><normalfont><b>$profilefield[title]</b></normalfont></td>
<td bgcolor="$backcolor"><normalfont><a target="_blank" href="$profilefield[value]">$profilefield[value]</a> </normalfont></td>
</tr>
Now, the problem is, that turns *ALL* of my custom fields into URLs. Obviously, that is a bad thing.
Is there any way to only have it change a couple specific ones into URLs?
I don't imagine if() statements work here. :p
Threshold
06-03-2003, 07:40 PM
Today at 04:32 PM Boofo said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=404019#post404019)
Look in functions.php for profile[fieldx].
Be sure to replace the x with the profile field number you are looking for.
Ok, I am looking through that file (admin/functions.php) and when I search for profile the only place it comes up is here:
Line 260: eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
Line 283: $post[profile]="";
Threshold
06-03-2003, 08:09 PM
Ugh. I hate reading code I do not fully understand. It makes me feeling like a programming n00b all over again.
As I read further, could it be THIS that I need to modify?
member.php lines 1379-1399:
// get extra profile fields
$customfields = '';
$profilefields=$DB_site->query("SELECT profilefieldid,required,title
FROM profilefield
WHERE hidden=0
ORDER BY displayorder");
while ($profilefield=$DB_site->fetch_array($profilefields)) {
if ($backcolor=="{firstaltcolor}") {
$backcolor="{secondaltcolor}";
$bgclass = "alt2";
} else {
$backcolor="{firstaltcolor}";
$bgclass = "alt1";
}
$profilefieldname="field$profilefield[profilefieldid]";
$profilefield[value]=$userinfo[$profilefieldname];
eval("\$customfields .= \"".gettemplate("getinfo_customfields")."\";");
}
Maybe this line (1395):
$profilefield[value]=$userinfo[$profilefieldname];
Should be changed to something like this? ==>
if($profilefieldname == "Your Real Life Picture" || $profilefieldname == "Your Character's Picture") {
$profilefield[value]= <a target="_blank" href="$userinfo[$profilefieldname]">$userinfo[$profilefieldname]</a> ;
} else {
$profilefield[value]=$userinfo[$profilefieldname];
}
or
if($profilefieldname == "Your Real Life Picture" || $profilefieldname == "Your Character's Picture") {
$profilefield[value]= "<a target="_blank" href="$userinfo[$profilefieldname]">$userinfo[$profilefieldname]</a>" ;
} else {
$profilefield[value]=$userinfo[$profilefieldname];
}
???
Threshold
06-03-2003, 09:15 PM
Problem solved due to something I read in another hack.
Zzed's hack found here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=38258&highlight=profile+field+URL) had code for making an image show up in a profile field.
It turns out I was looking in exactly the right place, but I just needed to know the proper php syntax to do this properly. I must say that I am shocked to learn that PHP uses "and" and "or" instead of "&&" and "||". What kind of language doesn't use && and || ???????????
Anyway, this is how I accomplished the hack:
I changed this line (1395):
$profilefield[value]=$userinfo[$profilefieldname];
to:
if(strstr($profilefield[title], "Your Real Life Picture") or strstr($profilefield[title], "Your Character's Picture")) {
$profilefield[value]="<a target=\"_blank\" href=\"$userinfo[$profilefieldname]\">$userinfo[$profilefieldname]</a>";
} else {
$profilefield[value]=$userinfo[$profilefieldname];
}
Problem solved! :)
Does anyone see any problems or flaws in my hack?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.