PDA

View Full Version : Adding A <br /> To Multiple Line Text Custom Profile Fields


RTMdotORG
08-08-2009, 11:41 PM
I've searched the forum for over an hour and have come up with nothing.

What I would like to do is show my members websites in the postbit.
I have it set to multiple line text, and when members add them, it looks like this:

Website(s):
www.?????.net www.?????.org www.?????.com

I would like it to look like

Website(s):
www.?????.net
www.?????.org
www.?????.com

any suggestions?

Lynne
08-09-2009, 02:34 AM
I wrote this plugin for someone who wanted to do something like this on the member.php page. I'm sure you can modify it for use in the postbit (use one of the postbit_ hook locations - and change the field id, of course):
if ($profilefield['profilefieldid'] == 16)
{
$find = ",";
$replace = "<br />";

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

RTMdotORG
08-09-2009, 05:25 AM
I wrote this plugin for someone who wanted to do something like this on the member.php page. I'm sure you can modify it for use in the postbit (use one of the postbit_ hook locations - and change the field id, of course):
if ($profilefield['profilefieldid'] == 16)
{
$find = ",";
$replace = "<br />";

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

Thanks, but it doesnt add a comma either. So how would replacing a comma with a break work?

Lynne
08-09-2009, 02:52 PM
I know that one won't work exactly without modification of the variable names (I said you would have to modify it to work). Post the code (and hook location) you tried.

RTMdotORG
08-09-2009, 03:23 PM
Hey Lynne,
You're the best at answering all these help issues, and yes I do have some knowledge of hooks and what not. But I cannot seem to figure this one out. Variables and Hooks are a challenge to me. It's one of those things where you search and try for hours and I'm overwhelmed. I previously saw your post with the above information, and I've tried. Isn't there an easier way?

Lynne
08-09-2009, 03:38 PM
That probably is the easiest way. This works for my simple field of comma separated items (I tested it on my field16, you need to change for yourself):
postbit_display_complete
if ($post['field16'])
{
$find = ",";
$replace = "<br />";

$post['field16']= str_replace($find, $replace, $post['field16']);
}Of course, also add the field to your postbit.

RTMdotORG
08-10-2009, 02:16 PM
Thanks... but it stills shows like this...

testing testing testing

instead of:

testing
testing
testing

Lynne
08-10-2009, 02:36 PM
Did you change the field id for the one you are using? It's usually best when you say something is not working if you post the exact code you used - in this case the exact plugin code and the exact code you put in the template.

RTMdotORG
08-10-2009, 02:44 PM
Heres the code i used:

if ($post['field5'])
{
$find = ",";
$replace = "<br />";

$post['field5']= str_replace($find, $replace, $post['field5']);
}

and heres the code i used in the postbit_legacy:
<if condition="$post['field5']"><div class="pbbox"><strong>Website(s):<br /></strong>
$post[field5]</div></if>

Lynne
08-10-2009, 02:47 PM
And you turned on the plugin? and the websites are separated by commas in the profile field? Or by a space? If a space, then the $find variable needs to be a space, not a comma.

RTMdotORG
08-10-2009, 03:04 PM
ok i got it to work with the space...
but when the user adds their websites...
its multiple line, so they dont put a space between, they push enter to go down to the next line, should i have them seperate using a space or is there another way to get around this?

Lynne
08-10-2009, 03:19 PM
You should ask them to do it using whatever method is easiest for you to deal with. I like commas, but I supposed you can do line breaks (google the code to use for $find if you want to use line breaks - maybe chr(11) ?).

RTMdotORG
08-10-2009, 03:29 PM
Thanks for your help Lynne! I just decided to have members separate with a space... shouldn't be hard for them to understand.