Tutorial.Custom profile fields

= Utilizing each Custom Profile Field =

Posted by Sniper_E in Utilizing each Custom Profile Field and STG topics (in Sep 28, 2007). I have been working with the and trying to figure it out. (with no luck) I've read a lot of topics on this at .com and in area51. I have not seen an answer to what I was looking for.

Here, I will show you how I was able to utilize and control the different custom profile fields we've added to our sites.

How to Control The different Custom Profile Fields
This is the section of the viewtopic_body.html which we are all having problems to get to work like we want it to.

{postrow.PROFILE_FIELD1_NAME}: {postrow.PROFILE_FIELD1_VALUE} I have side stepped that section above and utilized/customized the to get what we wanted. Highway of Life and Handyman have 3 custom profile fields they use on our STG site. [*]Favorite Team [*]Gender [*]Real Name

Watch how each custom profile field was sectioned off and called for individually in this code I have setup on our styles.

OPEN

styles/prosilver/template/viewtopic_body.html

FIND  {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

REPLACE WITH

 {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}  {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

OPEN

styles/subsilver2/template/viewtopic_body.html

FIND {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

REPLACE WITH {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

{postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

See how I'm calling for each specific custom profile field and placing each one where I want it in my page? You can place each field you've added anywhere in your page that you want it.

Now for the 3rd custom profile field, "Real Name" I want this field further up the page under the username.

For prosilver

FIND

 {postrow.POSTER_AVATAR}{postrow.POSTER_AVATAR}

{postrow.POST_AUTHOR_FULL} {postrow.POST_AUTHOR_FULL}  REPLACE WITH  {postrow.POSTER_AVATAR}{postrow.POSTER_AVATAR}

{postrow.POST_AUTHOR_FULL} {postrow.POST_AUTHOR_FULL} {postrow.custom_fields.PROFILE_FIELD_VALUE} 

For subsilver2

FIND

REPLACE WITH <td align="center" nowrap="nowrap">{postrow.custom_fields.PROFILE_FIELD_VALUE}</b>

I also worked with a couple of guys here who used a "Clan Site" custom profile field for their users. But, they didn't want the url which a user entered in to show up in that profile field. They wanted an image (a button) to be there that would link them to the url address.

Watch how this works with an image.... which we couldn't do before.

FIND {postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}

REPLACE WITH {postrow.custom_fields.PROFILE_FIELD_NAME}: <a href="{postrow.custom_fields.PROFILE_FIELD_VALUE}"><img src="{T_IMAGESET_PATH}/en/icon_contact_www.gif" alt="{postrow.custom_fields.PROFILE_FIELD_VALUE}" title="{postrow.custom_fields.PROFILE_FIELD_VALUE}"></a> Then to make your image clickable....

OPEN

/phpBB3/includes/functions_profile_fields.php

FIND $value = make_clickable($value);

REPLACE WITH // $value = make_clickable($value); Hope this helps out all those who have been battling this along with me.

End of Sniper's Topic post

=How to Hide one of the Custom Profile Fields in= ..

viewtopic_body.html
..

memberlist_view.html
..

UCP - User control panel
.. =How to Show the Custom Profile Fields in Other Pages=

overall_header.html
In order to show custom profile fields in overall_header.html, we need to add php codes to a file. So, we can add to includes/function.php While adding mood icon of Simple Mood mod to overall_header by using custom profile fields, I copied custom profile field codes from memberlist.php and modified them to use as a second custom profile field2. If we don't rename the second cpf, due to added codes in functions.php cpf fields values appear twice in member profiles and topic pages. So, we rename as custom_fields2, thus they will be seen once upon our selection.

Here is how I utilized to custom profile field view in overall_header. The user will his custom profile field value at overall_header.html

OPEN

/phpBB3/includes/functions.php

FIND

// The following assigns all _common_ variables that may be used at any point in a template.

ADD BEFORE

$profile_fields = array; if ($config['load_cpf_viewprofile'])//viewprofile custom profile view should be enabled, because it will controll this cpf {			include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); $cp = new custom_profile; $profile_fields = $cp->generate_profile_fields_template('grab', $user->data['user_id']); $profile_fields = (isset($profile_fields[$user->data['user_id']])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user->data['user_id']]) : array; } To control, enabel-disable this field, we should add a differen config value to database. In this method, $config['load_cpf_viewprofile'] member_profile_cpf switch control this added cpf entry.

FIND

'T_STYLESHEET_NAME'		=> $user->theme['theme_name'],

ADD AFTER 'S_CUSTOM_FIELDS2'		=> (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,

FIND // application/xhtml+xml not used because of IE

ADD BEFORE

if (!empty($profile_fields['row'])) {	$template->assign_vars($profile_fields['row']); }

if (!empty($profile_fields['blockrow'])) {	foreach ($profile_fields['blockrow'] as $field_data) {		$template->assign_block_vars('custom_fields2', $field_data); } }

OPEN

/phpBB3/styles/prosilver/template/overall_header.html

FIND

<a href="{U_PRINT_PM}" title="{L_PRINT_PM}" accesskey="p" class="print">{L_PRINT_PM}</a></li>

ADD AFTER

{custom_fields2.PROFILE_FIELD_NAME}:</dt> {custom_fields2.PROFILE_FIELD_VALUE}</dd>

Instead of the above edit in overall_header.html, we can prefer showing only one custom profile seen in overall_header. So, we shall do the edits below instead.

Considering Field name/title presented to the user: Mood FIND

<a href="{U_PRINT_PM}" title="{L_PRINT_PM}" accesskey="p" class="print">{L_PRINT_PM}</a></li>

ADD AFTER

{custom_fields2.PROFILE_FIELD_NAME}:</dt> {custom_fields2.PROFILE_FIELD_VALUE}</dd>

External pages
.. =List of Mods improving Custom Profile fields features= .. Those mods may referred to find sample codes in install.xml.

=See Also=
 * User_add
 * Tables/phpbb_profile_fields
 * Custom_profile_fields
 * a_profile