vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Reformatting profile fields (https://vborg.vbsupport.ru/showthread.php?t=214526)

Daryn 05-25-2009 06:53 PM

Reformatting profile fields
 
On our boards we have a lot of profile fields that use multiple check boxes. When vB displays these fields in the memberinfo page it does so as one giant comma seperated blob. What I'm wondering is if it's possible to get it to use line-breaks instead. For example currently the field is like this:

Field 1:
Item 1, Item 2, Item 3

I'd like it to be more like this:

Field1:
Item 1
Item 2
Item 3

Can anyone help with this? I spent hours yesterday digging through templates and not finding much.

Lynne 05-25-2009 07:30 PM

I think you'd have to write a plugin to take the profile field and do a str_replace of the commas with a line break. You'll have to look through the code to figure out where to do this. (If you are in debug mode, the hook locations will show on the bottom of the page and then you can search the php files to find those hooks and see which one to use.)

Daryn 05-25-2009 10:19 PM

That's a bit beyond my abilities to do. I'm no programmer so this is something I'd have to ask someone to do.

Lynne 05-25-2009 10:38 PM

Should be something simple like this (play with it if it isn't working right):

hook location: member_profileblock_profilefieldbit
PHP Code:

if ($profilefield['profilefieldid'] == xx)
{
$find ",";
$replace "<br />";

$profilefield['value']= str_replace($find$replace$profilefield['value']);


Replace xx with the field id.

Daryn 05-25-2009 10:57 PM

That seems to work. Will it take multiple values?

EDIT: Hm, no, it doesn't seem to.

Lynne 05-25-2009 11:44 PM

It works just fine with the one field I have on my test site that I put commas into. If it isn't working with multiple field ids, then you should play with it and then post your code here so we can see it.

Daryn 05-26-2009 01:03 AM

Works just fine if it's one field. If I want to use more than one field though I don't know. I said before I'm no PHP programmer.

Lynne 05-26-2009 03:33 AM

You can use and OR or use in_array.
PHP Code:

if ($profilefield['profilefieldid'] == xx OR $profilefield['profilefieldid'] == yy

or
PHP Code:

if (in_array($profilefield['profilefieldid'] , array(xx,yy))) 

Either of those should work.

Daryn 05-26-2009 04:01 AM

I'll give them a try in the morning. Thanks for all the help, it is appreciated.

--------------- Added [DATE]1243364818[/DATE] at [TIME]1243364818[/TIME] ---------------

Tried out the array statement. Works just fine and is easy to add to. I'm wondering though, is it possible to do this by profilefield type rather than ID?


All times are GMT. The time now is 09:34 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.04257 seconds
  • Memory Usage 1,734KB
  • 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_php_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