[TUTORIAL]Utilizing each Custom Profile Field

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Sniper_E
Registered User
Posts: 813
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

[TUTORIAL]Utilizing each Custom Profile Field

Post by Sniper_E »

I have been working with the <!-- IF postrow.S_PROFILE_FIELD1 --> 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.

This is the section of the viewtopic_body.html which we are all having problems to get to work like we want it to.

Code: Select all

					<!-- 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/subsilver2/template/viewtopic_body.html

FIND

Code: Select all

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

Code: Select all

					<!-- 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 -->
OPEN styles/prosilver/template/viewtopic_body.html

FIND

Code: Select all

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

Code: Select all

		<!-- 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 -->
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 subsilver2
FIND

Code: Select all

			<!-- IF postrow.ONLINE_IMG -->
REPLACE WITH

Code: Select all

                        <!-- 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 -->
For prosilver
FIND

Code: Select all

			<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

Code: Select all

			<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" -->
					&nbsp; &nbsp; <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>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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

Code: Select all

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

Code: Select all

                   <!-- 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

Code: Select all

$value = make_clickable($value);
REPLACE WITH

Code: Select all

// $value = make_clickable($value);
Hope this helps out all those who have been battling this along with me.
Last edited by Sniper_E on Fri Oct 19, 2007 6:39 pm, edited 4 times in total.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:
supertuxs
Registered User
Posts: 7
Joined: Fri Sep 21, 2007 11:07 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by supertuxs »

Ok, thanks.

And how search with custom fields?
iNTaYkE
Registered User
Posts: 6
Joined: Sun Oct 07, 2007 10:06 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by iNTaYkE »

I still can't get this to work? =/

Code: Select all

        <!-- BEGIN custom_fields -->
             <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
          <!-- END custom_fields -->
          <!-- BEGIN custom_fields -->
                   <!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Fav. S1 Finalist" -->
             <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
                   <!-- ENDIF -->
          <!-- END custom_fields -->
I also tried with the field ID.
User avatar
Sniper_E
Registered User
Posts: 813
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Sniper_E »

Leave this part out....

Code: Select all

        <!-- BEGIN custom_fields -->
             <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
          <!-- END custom_fields -->
Use just this for each custom profile field....

Code: Select all

          <!-- BEGIN custom_fields -->
                   <!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Fav. S1 Finalist" -->
             <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
                   <!-- ENDIF -->
          <!-- END custom_fields -->
Is "Fav. S1 Finalist" the name you entered in as the Field name/title presented to the user:
in the ACP/Users And Groups/Custom profile fields?
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:
richey
Registered User
Posts: 616
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by richey »

I'm stuck.

I have defined 2 custom fields, "geschlecht" and "alter" in the Admin panel and defined them as "required".
In viewtopic_body, I coded:

Code: Select all

<!-- BEGIN custom_fields -->
{custom_fields.PROFILE_FIELD_NAME} <!-- check if something is displayed at all -->
{postrow.custom_fields.PROFILE_FIELD_NAME} <!-- check if something is displayed at all -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq 'geschlecht' -->
{postrow.custom_fields.PROFILE_FIELD_VALUE}
<!-- ENDIF -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq 'alter' -->
<!-- IF  custom_fields.PROFILE_FIELD_VALUE neq 0 -->
, {custom_fields.PROFILE_FIELD_VALUE}
<!-- ENDIF -->
<!-- ENDIF -->
<!-- END custom_fields -->
but nothing at all is displayed, even though all users have filled these fields in their profile.

any idea what might cause the "hidden custom fields"? 8)
r.
.
User avatar
Sniper_E
Registered User
Posts: 813
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Sniper_E »

@iNTaYkE, did you get your problem resolved?

@richey, in your ACP.... is "geschlecht" and "alter" the name you entered in as the
Field name/title presented to the user:? That is the name you put in the quotes.
You are not suppose to use the Field identification: name.

This one is for prosilver. Use the correct name in the "quotes"

Code: Select all

          <!-- BEGIN custom_fields -->
                   <!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "geschlecht" -->
             <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 "alter" -->
             <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
                   <!-- ENDIF -->
          <!-- END custom_fields -->
This one is for subsilver2. Use the correct name in the "quotes"

Code: Select all

               <!-- BEGIN custom_fields -->
               <!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "geschlecht" -->
<b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}<br />
               <!-- ENDIF -->
   
               <!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "alter" -->
<b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}<br />
               <!-- ENDIF -->
               <!-- END custom_fields -->
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:
janmyszkier
Registered User
Posts: 294
Joined: Tue Oct 09, 2007 4:53 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by janmyszkier »

can I ask you to look into this and help? http://www.phpbb.com/community/viewtopi ... 5#p3397304

Thank you in advance
AttilaG
Registered User
Posts: 20
Joined: Mon Oct 29, 2007 4:18 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by AttilaG »

Hi

Everybody places the custom profile fields into "viewtopic_body.html". But what is the code to place it into "index_body.html"??

I created a boolean field to switch on and off the shoutbox on my index page. Unfortunally I can't get the value displayed on the page or used in a condition....

Thanks
-- Attila
AttilaG
Registered User
Posts: 20
Joined: Mon Oct 29, 2007 4:18 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by AttilaG »

Sorry for pushing... Does nobody has an idea how to use the custom profile fields on the index page?

-- Attila
AttilaG
Registered User
Posts: 20
Joined: Mon Oct 29, 2007 4:18 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by AttilaG »

Ok, I found a way:
Now I do a sql query in index.php and pass the result as a variable to index_body.html.

-- Attila
kevinp63
Registered User
Posts: 33
Joined: Tue Jan 29, 2008 3:22 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by kevinp63 »

Created Custom Profile Field - Real Name

field identification: real_name
Field name presented to user: Real Name

Trying to display this next to username on viewtopic_ body

Code: Select all

			<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" -->
               &nbsp; &nbsp; <b><i>{postrow.custom_fields.PROFILE_FIELD_VALUE}</i></b>
               <!-- ENDIF -->
            <!-- END custom_fields -->

			</dt>
Not getting anything....

Thanks for the help!
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52056
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Hmmm...

Have you set custom fields to display in viewtopic? Have you set the particular custom field as displayable?
kevinp63
Registered User
Posts: 33
Joined: Tue Jan 29, 2008 3:22 pm

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by kevinp63 »

How do you do that per page?

"Display profile field" is set to yes
and "Display in user control panel" set to Yes

And it does display whil viewing a profile..

is that what you mean?

Thanks again.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52056
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

On Load Settings page set "Display custom profile fields on topic pages" to Yes.
mdvaldosta
Registered User
Posts: 353
Joined: Sat Mar 26, 2005 12:26 am
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by mdvaldosta »

Very helpful. It's a shame that such great custom field code is included in phpBB3 but not coded into themes...
Locked

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