View Full Version : Reformatting profile fields
Daryn
05-25-2009, 06:53 PM
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
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.
if ($profilefield['profilefieldid'] == xx OR $profilefield['profilefieldid'] == yy)
or
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 1243364818 at 1243364818 ---------------
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?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.