Page 1 of 2

Working on profile field

Posted: Sun Oct 21, 2007 6:23 pm
by CelaCG
I've set up a custom profile field on my forum, however the max length is at 255 and I'd like to increase that. This is the query I used for installation:

Code: Select all

ALTER TABLE phpbb_users ADD user_fieldnamehere VARCHAR(255) NOT NULL;
And I'm pretty sure that's what defined the max length. If so, what would I execute to change it?

Also, I was wondering if someone could help me allow BBCode and smilies in this field.

Thanks.

Re: Working on profile field

Posted: Mon Oct 22, 2007 3:12 am
by Noobarmy
changing the data type is needed to be done. soemthing like text will suit longer strings. so run query:

Code: Select all

ALTER TABLE phpbb_users MODIFY user_fieldnamehere text NOT NULL;
now to parse bbcode & smilies you need two things:

Code: Select all

   require_once($phpbb_root_path.'includes/bbcode.'.$phpEx);
   require_once($phpbb_root_path.'includes/functions_post.'.$phpEx);
       $bbcode_uid = make_bbcode_uid();
       $message = bbencode_first_pass($message, $bbcode_uid);
first you parse the message with the bbcode_uid. you then need to store $bbcode_uid and $message (which will be hte value of the new field, change this as appropriate)

then when it comes to retrieving teh data do the following:

Code: Select all

      require_once($phpbb_root_path.'includes/bbcode.'.$phpEx);
      require_once($phpbb_root_path.'includes/functions_post.'.$phpEx);
// BBCOde
         $message = bbencode_second_pass($message, $bbcode_uid);
// Smilies
         $message = smilies_pass($message);
where $message and $bccode_uid should be taken form the database and be the same values as in the above code block

Hope that helps :ugeek:

Re: Working on profile field

Posted: Mon Oct 22, 2007 11:54 pm
by CelaCG
Thanks, but is there a way to actually set a limit on characters? If not, no problem.

I've decided not to parse the BBCode, but I'm confused about displaying line breaks. If you type:
something
like
this
in your profile, it'll just come out as "something like this". Is it possible to change this behavior (just for this field)?

Thanks for your time, I appreciate it.

Re: Working on profile field

Posted: Tue Oct 23, 2007 7:07 am
by Noobarmy
line breaks are sent as \n, but once you echo that out it wont display as new line except in the source....which is a gret help eh :lol:

you need to do something like this:

Code: Select all

str_replace( "\n", '<br />', $code);
where $code is your field. thsi should then display a new line :D

Re: Working on profile field

Posted: Tue Oct 23, 2007 9:18 pm
by CelaCG
Is there a specific place I should put this, or is there more to the code? I've inserted this and it changes nothing.

Re: Working on profile field

Posted: Tue Oct 23, 2007 10:50 pm
by AGC
Change the string "$code " to the string you want to parse.
Ex: if you want to parse $profile than replace $code with $profile

Re: Working on profile field

Posted: Wed Oct 24, 2007 12:11 am
by CelaCG
Yes, I did that, but nothing happened. Where was I supposed to place this code?

Re: Working on profile field

Posted: Wed Oct 24, 2007 6:14 am
by Noobarmy
teh best place is before your about to output it/when your sending it ot hte template

Re: Working on profile field

Posted: Wed Oct 24, 2007 9:48 pm
by CelaCG
Wow, I'm stuck. Does this line of code stand alone or is there anything else I need to write around it?

Re: Working on profile field

Posted: Thu Oct 25, 2007 5:45 am
by Noobarmy
well the result of that part of coding will give you what you want as ouptput, how you deal with it is up to you. you coudl put it into the template assign directly or just reassign it to $code

Code: Select all

$code = str_replace( "\n", '<br />', $code);

Re: Working on profile field

Posted: Thu Oct 25, 2007 11:59 pm
by CelaCG
How would you go about this?

Maybe I'm way off. I've been trying this usercp_viewprofile.php, is that the correct file? If so, where exactly does it go?

Re: Working on profile field

Posted: Mon Oct 29, 2007 2:52 am
by CelaCG
Alright, I finally got it. Thanks for all your help, it works perfectly.

Re: Working on profile field

Posted: Wed Dec 05, 2007 1:20 pm
by thedjmixman
Noobarmy

I'd like to thank you for the awesome help you gave CelaCG in this thread. I have numerous textarea's on my site and your clear advice here has enabled me to lose the terrible RTE's I had - And have been able to replicate the forum's BBCode as their replacements :)

I thought I was going to be in for a hard time with this as it's not always so easy to find help so clear when you are doing a search for answers. This thread was the first one thrown at me.

Once again. Cheers!
You have saved many grey hairs :lol:

Re: Working on profile field

Posted: Sun Jan 06, 2008 2:25 am
by Spaniel
I'm trying to enable line breaks in the user_interests field, which i've already changed to a text box in the database.

I can't work out where to put the script

Code: Select all

str_replace( "\n", '<br />', $code);
for that particular field and what do I put before it and change $code to?


Much appreciated.

Re: Working on profile field

Posted: Mon Jan 07, 2008 1:33 pm
by Brf
That would be where it is being displayed, in usercp_viewprofile I am assuming.....