[TUTORIAL]Utilizing each Custom Profile Field

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52048
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Where are you trying to display it?
Wulfric
Registered User
Posts: 26
Joined: Fri Nov 13, 2009 8:09 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Wulfric »

I am trying to display it in a custom page I added using the Knowledgebase post about adding a custom page.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52048
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Then your custom page will have to pull the value of the profile field like this:

Code: Select all

		$user->get_profile_fields( $user->data['user_id'] );
		$user_fields = $user->profile_fields;
		$full_name =  (isset( $user_fields['pf_full_name'] )) ? $user_fields['pf_full_name'] : '';
		$template->assign_vars(array(
			'FULL_NAME'			=> $full_name
		));
Then in your template, use:

Code: Select all

{FULL_NAME}
Wulfric
Registered User
Posts: 26
Joined: Fri Nov 13, 2009 8:09 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Wulfric »

Works like charm!
Thanks! how do i add more variables?
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 »

Wulfric wrote:Well, I have two custom fields on my forums, and one of them is link. I viewtopic_body.html I want it to be shown as the link href'd to the other field.
Cant see how to do it.
Can you please help?
How do you have these two setup as custom profile fields?
Is one a url address that you enter in and the other one that you want that cpf linked to is what?
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:
User avatar
adcantu
Registered User
Posts: 212
Joined: Wed Apr 21, 2004 12:08 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by adcantu »

I'm trying to add an image below the profile icons. I created a custom field so that users can specify a number for their specific image. I have the image working correctly, the problem is that now I also have it showing as a profile field, " Image Selection: 2 ". Is there a way that I can only have it shown once, as in not the text but just to load the image? I also have other custom profile fields so I don't want to just remove the custom fields call altogether.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52048
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Either you can remove the loop altogether and specify separate code for each profile field, or you can put an IF in the loop to make it skip the one field.
User avatar
adcantu
Registered User
Posts: 212
Joined: Wed Apr 21, 2004 12:08 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by adcantu »

Thanks Brf. I tried a few variations to use an IF in the loop but to no avail. I only had a few extra custom fields so I went ahead and called each one specifically and removed the loop as you suggested.
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 »

adcantu wrote:I'm trying to add an image below the profile icons. I created a custom field so that users can specify a number for their specific image. I have the image working correctly, the problem is that now I also have it showing as a profile field, " Image Selection: 2 ". Is there a way that I can only have it shown once, as in not the text but just to load the image? I also have other custom profile fields so I don't want to just remove the custom fields call altogether.
Yes, you can make an image show up from the number they entered in their cpf.
And you can omit a cpf from showing up. What are they created as? What name did you give them?
Are your images 1.gif, 2.gif, etc...?

Example for a number image:

Code: Select all

		<!-- IF postrow.S_PROFILE_NUMBER -->
			<dd><strong>{postrow.PROFILE__NAME}:</strong> <img src="./images/{postrow.PROFILE_NUMBER_VALUE}.gif" alt="{postrow.PROFILE_NUMBER_VALUE}" /></dd>
		<!-- ENDIF -->
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:
Fishhead
Registered User
Posts: 13
Joined: Sun Sep 20, 2009 12:13 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Fishhead »

This thread has been going on for sometime, I hope that I am not too late to get some help. Like others I wish to display some custom profile fields in my membership list. Early in this thread it one commenter suggested making changes to the memberlist_body.html file. One change was to include headings as such:

Code: Select all

<th>First Name</th>
and

Code: Select all

<td><!--IF memberrow.PROFILE_FIRST_NAME_VALUE -->{memberrow.PROFILE_FIRST_NAME_VALUE}<!-- ELSE -->&nbsp;<!-- ENDIF --></td>
I in ACP I have set display to "yes", check the visibility boxes, and set the load settings to yes. I transfered the file and clear the cache. But when I go to the membership list I get this error message.
Parse error: syntax error, unexpected T_ELSE in /home/lfps42un/public_html/Forum/includes/template.php(230) : eval()'d code on line 136
If I hit back arrow and click on membership once again the error message has change to indicate the membership_body.html file, as below:
Parse error: syntax error, unexpected T_ELSE in /home/lfps42un/public_html/Forum/cache/tpl_prosilver_memberlist_body.html.php on line 136
Line 136 in the membership_body.html file is the following:

Code: Select all

<!-- DEFINE $S_MEMBER_HEADER = 1 -->
What am I doing wrong?
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52048
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Fishhead wrote: What am I doing wrong?
Posting one line of code is not helping.
Fishhead
Registered User
Posts: 13
Joined: Sun Sep 20, 2009 12:13 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Fishhead »

OK, below is the entire section of code from memberlist_body.html that deals with the memberrow. I seperated the new lines with spaces. I have tried using lowercase and uppercase for the field names, but that produced no change. I also tried having only the new column name included, and that does work, but as expected shifting data values to the wrong column.

Code: Select all

<!-- IF S_LEADERS_SET or not S_SHOW_GROUP or not .memberrow -->
	<div class="forumbg forumbg-table">
		<div class="inner"><span class="corners-top"><span></span></span>

		<table class="table1" cellspacing="1" id="memberlist">
		<thead>
		<tr>
			<th class="name"><span class="rank-img"><a href="{U_SORT_RANK}">{L_RANK}</a></span><a href="{U_SORT_USERNAME}"><!-- IF S_SHOW_GROUP and .memberrow -->{L_GROUP_LEADER}<!-- ELSE -->{L_USERNAME}<!-- ENDIF --></a></th>
			<th class="posts"><a href="{U_SORT_POSTS}#memberlist">{L_POSTS}</a></th>

				<th>First Name</th>
				
			<th class="info"><a href="{U_SORT_WEBSITE}#memberlist">{L_WEBSITE}</a>{L_COMMA_SEPARATOR}<a href="{U_SORT_LOCATION}">{L_LOCATION}</a></th>
			<th class="joined"><a href="{U_SORT_JOINED}#memberlist">{L_JOINED}</a></th>
			<!-- IF U_SORT_ACTIVE --><th class="active"><a href="{U_SORT_ACTIVE}#memberlist">{L_LAST_ACTIVE}</a></th><!-- ENDIF -->
		</tr>
		</thead>
		<tbody>
	<!-- ENDIF -->
		<!-- BEGIN memberrow -->
			<!-- IF S_SHOW_GROUP -->
				<!-- IF not memberrow.S_GROUP_LEADER and not $S_MEMBER_HEADER -->
				<!-- IF S_LEADERS_SET and memberrow.S_FIRST_ROW -->
				<tr class="bg1">
					<td colspan="<!-- IF U_SORT_ACTIVE -->5<!-- ELSE -->4<!-- ENDIF -->">&nbsp;</td>
				</tr>
				<!-- ENDIF -->
<!-- IF S_LEADERS_SET -->
		</tbody>
		</table>

	<span class="corners-bottom"><span></span></span></div>
</div>
<!-- ENDIF -->
<div class="forumbg">
	<div class="inner"><span class="corners-top"><span></span></span>

	<table class="table1" cellspacing="1">
	<thead>
	<tr>
	<!-- IF not S_LEADERS_SET -->
		<th class="name"><span class="rank-img"><a href="{U_SORT_RANK}">{L_RANK}</a></span><a href="{U_SORT_USERNAME}"><!-- IF S_SHOW_GROUP -->{L_GROUP_MEMBERS}<!-- ELSE -->{L_USERNAME}<!-- ENDIF --></a></th>
			<th class="posts"><a href="{U_SORT_POSTS}#memberlist">{L_POSTS}</a></th>
			<th class="info"><a href="{U_SORT_WEBSITE}#memberlist">{L_WEBSITE}</a>{L_COMMA_SEPARATOR}<a href="{U_SORT_LOCATION}">{L_LOCATION}</a></th>
			<th class="joined"><a href="{U_SORT_JOINED}#memberlist">{L_JOINED}</a></th>
			<!-- IF U_SORT_ACTIVE --><th class="active"><a href="{U_SORT_ACTIVE}#memberlist">{L_LAST_ACTIVE}</a></th><!-- ENDIF -->
	<!-- ELSEIF S_SHOW_GROUP -->
		<th class="name">{L_GROUP_MEMBERS}</th>
		<th class="posts">&nbsp;</th>
		<th class="info">&nbsp;</th>
		<th class="joined">&nbsp;</th>
		<!-- IF U_SORT_ACTIVE --><th class="active">&nbsp;</th><!-- ENDIF -->
	<!-- ENDIF -->
	</tr>
	</thead>
	<tbody>
					<!-- DEFINE $S_MEMBER_HEADER = 1 -->
				<!-- ENDIF -->
			<!-- ENDIF -->

	<tr class="<!-- IF memberrow.S_ROW_COUNT is even -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
		<td><!-- IF memberrow.RANK_IMG --><span class="rank-img">{memberrow.RANK_IMG}</span><!-- ELSE --><span class="rank-img">{memberrow.RANK_TITLE}</span><!-- ENDIF --><!-- IF S_IN_SEARCH_POPUP and not S_SELECT_SINGLE --><input type="checkbox" name="user" value="{memberrow.USERNAME}" /> <!-- ENDIF -->{memberrow.USERNAME_FULL}<!-- IF S_SELECT_SINGLE --><br />[&nbsp;<a href="#" onclick="insert_single('{memberrow.A_USERNAME}'); return false;">{L_SELECT}</a>&nbsp;]<!-- ENDIF --></td>
		<td class="posts"><!-- IF memberrow.POSTS and S_DISPLAY_SEARCH --><a href="{memberrow.U_SEARCH_USER}" title="{L_SEARCH_USER_POSTS}">{memberrow.POSTS}</a><!-- ELSE -->{memberrow.POSTS}<!-- ENDIF --></td>

		<td><!--IF memberrow.PROFILE_first_name_VALUE -->{memberrow.PROFILE_first_name_VALUE}<!-- ELSE -->&nbsp;<!-- ENDIF --></td>
		

		<td class="info"><!-- IF memberrow.U_WWW or memberrow.LOCATION --><!-- IF memberrow.U_WWW --><div><a href="{memberrow.U_WWW}" title="{L_VISIT_WEBSITE}: {memberrow.U_WWW}">{memberrow.U_SHORT_WWW}</a></div><!-- ENDIF --><!-- IF memberrow.LOCATION --><div>{memberrow.LOCATION}</div><!-- ENDIF --><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
		<td>{memberrow.JOINED}</td>
		<!-- IF S_VIEWONLINE --><td>{memberrow.VISITED}&nbsp;</td><!-- ENDIF -->
	</tr>
		<!-- BEGINELSE -->
	<tr class="bg1">
		<td colspan="<!-- IF S_VIEWONLINE -->5<!-- ELSE -->4<!-- ENDIF -->">{L_NO_MEMBERS}</td>
	</tr>
		<!-- END memberrow -->
Fishhead
Registered User
Posts: 13
Joined: Sun Sep 20, 2009 12:13 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Fishhead »

I caught my mistake. I am either doing this too late at night or I am becoming too blind to be effective. I failed to have a space following <!-- before the IF.
<td><!--IF memberrow.PROFILE_first_name_VALUE
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52048
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Brf »

Your error is here:

Code: Select all

<td><!--IF memberrow.PROFILE_first_name_VALUE -->{memberrow.PROFILE_first_name_VALUE}<!-- ELSE -->&nbsp;<!-- ENDIF --></td>
You need a space before the "IF".

Also, it should be

Code: Select all

memberrow.PROFILE_FIRST_NAME_VALUE
Lastpost
Registered User
Posts: 74
Joined: Thu Feb 04, 2010 7:09 am

Re: [TUTORIAL]Utilizing each Custom Profile Field

Post by Lastpost »

I have got a question about this to, I'm trying to use the custom fields to style the user profiles.

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "logo" -->
<style type="text/css">
#page-bg {background:  url({custom_fields.PROFILE_FIELD_VALUE})  repeat-y; margin-top: 0px;
background-attachment: fixed;
 }
</style>
<!-- ENDIF -->
<!-- END custom_fields -->
Above works, when I enter a link it shows the background selected and if the field contains an error ór isn't filled in, it just shows the stuff in my css file.
But I would like to combine things like this:

Code: Select all

<style type="text/css">
#page-bg {background: #{custom_fields.PROFILE_FIELD_VALUE} url({custom_fields.PROFILE_FIELD_VALUE1})  repeat-{custom_fields.PROFILE_FIELD_VALUE2}; margin-top: 0px;
background-attachment: {custom_fields.PROFILE_FIELD_VALUE3};
 }
</style>
So it shows the background-color, the image and some styling, is it possible to do it like that?
If I'm trying to show them seperate (2 differend if statements) it will only turn the page the color I have set and overwrites the background image that is also inserted.

I hope someone can show me the right direction. :P
Locked

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