Working on profile field

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Working on profile field

Post 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.
User avatar
Noobarmy
Registered User
Posts: 2388
Joined: Tue Apr 04, 2006 6:15 pm
Location: London
Contact:

Re: Working on profile field

Post 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:
Image
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post 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.
User avatar
Noobarmy
Registered User
Posts: 2388
Joined: Tue Apr 04, 2006 6:15 pm
Location: London
Contact:

Re: Working on profile field

Post 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
Image
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post 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.
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: Working on profile field

Post 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
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post by CelaCG »

Yes, I did that, but nothing happened. Where was I supposed to place this code?
User avatar
Noobarmy
Registered User
Posts: 2388
Joined: Tue Apr 04, 2006 6:15 pm
Location: London
Contact:

Re: Working on profile field

Post by Noobarmy »

teh best place is before your about to output it/when your sending it ot hte template
Image
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post by CelaCG »

Wow, I'm stuck. Does this line of code stand alone or is there anything else I need to write around it?
User avatar
Noobarmy
Registered User
Posts: 2388
Joined: Tue Apr 04, 2006 6:15 pm
Location: London
Contact:

Re: Working on profile field

Post 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);
Image
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post 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?
CelaCG
Registered User
Posts: 11
Joined: Fri Aug 03, 2007 7:31 pm

Re: Working on profile field

Post by CelaCG »

Alright, I finally got it. Thanks for all your help, it works perfectly.
thedjmixman
Registered User
Posts: 21
Joined: Sat Aug 30, 2003 2:54 pm
Location: Dartford, Kent, UK
Contact:

Re: Working on profile field

Post 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:
Spaniel
Registered User
Posts: 159
Joined: Sun Dec 30, 2007 3:51 am

Re: Working on profile field

Post 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.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53412
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Working on profile field

Post by Brf »

That would be where it is being displayed, in usercp_viewprofile I am assuming.....
Post Reply

Return to “[2.0.x] MOD Writers Discussion”