phpBB

Development Wiki

Tutorial.Custom profile fields

From phpBB Development Wiki

Revision as of 19:45, 27 September 2008 by Highway of life (Talk | contribs)

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.

	<!-- IF postrow.S_PROFILE_FIELD1 -->
		<!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
		<br /><b>{postrow.PROFILE_FIELD1_NAME}:</b> {postrow.PROFILE_FIELD1_VALUE}
	<!-- ENDIF -->

I have side stepped that section above and utilized/customized the <!-- BEGIN custom_fields --> 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

	<!-- BEGIN custom_fields -->
		<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
	<!-- END custom_fields -->

REPLACE WITH


	<!-- BEGIN custom_fields -->
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Favorite Team" -->
			<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
		<!-- ENDIF -->
	
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Gender" -->
			<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
		<!-- ENDIF -->
	<!-- END custom_fields -->

OPEN

styles/subsilver2/template/viewtopic_body.html

FIND

	<!-- BEGIN custom_fields -->
		<br /><b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}		
	<!-- END custom_fields -->

REPLACE WITH

	<!-- BEGIN custom_fields -->
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Favorite Team" -->
			<b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}<br />
		<!-- ENDIF -->
	
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Gender" -->
			<b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}<br />
		<!-- ENDIF -->
	<!-- END custom_fields -->


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

	<dt>
		<!-- IF postrow.POSTER_AVATAR -->
			<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />
		<!-- ENDIF -->
		<!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->
	</dt>

REPLACE WITH

	<dt>
		<!-- IF postrow.POSTER_AVATAR -->
			<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />
		<!-- ENDIF -->
		<!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->
		<!-- BEGIN custom_fields -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Real Name" -->
			    <b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="color: {postrow.POST_AUTHOR_COLOUR}"<!-- ENDIF -->><i>{postrow.custom_fields.PROFILE_FIELD_VALUE}</i></b>
			<!-- ENDIF -->
		<!-- END custom_fields -->
 	</dt>

For subsilver2

FIND

	<!-- IF postrow.ONLINE_IMG -->

REPLACE WITH

	<!-- BEGIN custom_fields -->
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Real Name" -->
			<tr>
				<td align="center" nowrap="nowrap"><b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="color: {postrow.POST_AUTHOR_COLOUR}"<!-- ENDIF -->><i>{postrow.custom_fields.PROFILE_FIELD_VALUE}</i></b></td>
			</tr>
		<!-- ENDIF -->
	<!-- END custom_fields -->
	<!-- IF postrow.ONLINE_IMG -->

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

	<!-- BEGIN custom_fields -->
		<br /><b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}
	<!-- END custom_fields -->

REPLACE WITH

	<!-- BEGIN custom_fields -->
		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Clan Site" -->
			<b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b>  <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>
		<!-- ENDIF -->
	<!-- END custom_fields -->

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

memberlist_body.html

overall_header.html

External pages

..

List of Mods improving Custom Profile fields features

.. Those mods may referred to find sample codes in install.xml.

See Also