vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Make other Profile fields parse as URLs? (https://vborg.vbsupport.ru/showthread.php?t=53803)

Threshold 06-03-2003 07:01 PM

Make other Profile fields parse as URLs?
 
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

Quote:

<tr>
<td bgcolor="$backcolor"><normalfont><b>$profilefield[title]</b></normalfont></td>
<td bgcolor="$backcolor"><normalfont>$profilefield[value]&nbsp;</normalfont></td>
</tr>
To test this, I changed that code to this:
Quote:


<tr>
<td bgcolor="$backcolor"><normalfont><b>$profilefield[title]</b></normalfont></td>
<td bgcolor="$backcolor"><normalfont><a target="_blank" href="$profilefield[value]">$profilefield[value]</a>&nbsp;</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

Quote:

Today at 04:32 PM Boofo said this in Post #5
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:
Code:

  // 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? ==>

Code:

    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

Code:

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

Quote:

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?


All times are GMT. The time now is 05:54 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.02477 seconds
  • Memory Usage 1,743KB
  • 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
  • (3)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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