Customize UCP fields

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Pope94/IA
Registered User
Posts: 21
Joined: Sun Jan 16, 2011 4:45 pm

Customize UCP fields

Post by Pope94/IA » Wed Feb 09, 2011 1:02 am

Sorry if this thread is in the wrong forum. Im not sure where to post it considering its not really mod related or style related..

My website is http://www.the-hunting-place.com/forum/
Im using subsilver2
Im editing two files: memberlist_view.html and ucp_profile_profile_info.html

What im trying to do is customize my custom profile fields in my ucp so I can position them where I want and what ever ones I want, just like what you can in the memberlist_view.html using this code...

Code: Select all

                                       <!-- IF S_PROFILE_FIELDNAME -->
				<tr>
					<td class="gen" align="right">{PROFILE_FIELDNAME_NAME}: </td>
					<td><b class="genmed">&nbsp;{PROFILE_FIELDNAME_VALUE}</b></td>
				</tr>
			<!-- ENDIF -->
That code allows you to put them where you want. I want that to work with my ucp also using the same profile fields.

Right at the momment it displays all the custom profile fields in order and im wanting to move them around.

This is the default code that displays them all. What should I change in this to just display individual fields?

Code: Select all

<!-- BEGIN profile_fields -->
	<tr> 
		<td class="row1" width="35%">
			<b class="genmed">{profile_fields.LANG_NAME}: </b>
			<!-- IF profile_fields.S_REQUIRED --><b>*</b><!-- ENDIF -->
			<!-- IF profile_fields.LANG_EXPLAIN --><br /><span class="gensmall">{profile_fields.LANG_EXPLAIN}</span><!-- ENDIF -->
		</td>
		<td class="row2">{profile_fields.FIELD}<!-- IF profile_fields.ERROR --><br /><span class="gensmall error">{profile_fields.ERROR}</span><!-- ENDIF --></td>
	</tr>
<!-- END profile_fields -->

Sorry if im not being clear with what im asking. Im not that good at explaing things. :D I can picture it in my brain but for some reason it doesn't come out as I want.

Maybe if I showed somethings I was testing out, it will help.
Color red is what I tried changing
<!-- BEGIN profile_fields_FIELDNAME -->
<tr>
<td class="row1" width="35%">
<b class="genmed">{profile_fields.FIELDNAME}: </b>
<!-- IF profile_fields.S_REQUIRED --><b>*</b><!-- ENDIF -->
<!-- IF profile_fields.LANG_EXPLAIN --><br /><span class="gensmall">{profile_fields.LANG_EXPLAIN}</span><!-- ENDIF -->
</td>
<td class="row2">{profile_fields.FIELD_FIELDNAME}<!-- IF profile_fields.ERROR --><br /><span class="gensmall error">{profile_fields.ERROR}</span><!-- ENDIF --></td>
</tr>
<!-- END profile_fields_FIELDNAME -->
Well obvisiously what I edited didn't work but it might help explain what im going for here...

Any help will be appreciated.

Thanks guys and gals!
Last edited by Oyabun1 on Thu Jan 15, 2015 3:00 am, edited 1 time in total.
Reason: Moved from 3.0.x Support forum

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Wed Feb 09, 2011 9:02 am

Open /includes/functions_profile_fields.php and find:

Code: Select all

            $template->assign_block_vars('profile_fields', array( 
Below, add:

Code: Select all

                'IDENT'=> $row['field_ident'], 
Now you can identify each custom profile field in the template you want to edit, i.e. for /styles/subsilver2/template/ucp_profile_profile_info.html you could do:

Code: Select all

<!-- BEGIN profile_fields -->
<!-- IF profile_fields.IDENT eq 'firstname' -->
	<b>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</b>
<!-- ELSEIF profile_fields.IDENT eq 'lastname' -->
	<i>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</i>
<!-- ELSEIF profile_fields.IDENT eq ...
	...
<!-- ENDIF -->
<!-- END profile_fields -->
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Pope94/IA
Registered User
Posts: 21
Joined: Sun Jan 16, 2011 4:45 pm

Re: Customize UCP fields

Post by Pope94/IA » Fri Feb 11, 2011 1:28 am

Thanks for the reply but it doesn't seem to be working.
Using your code I replaced firstname and lastname with the names of my fields.. I am using bow as one and arrows as the other but it doesn't seem to show in the user control panel.

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Fri Feb 11, 2011 6:45 am

Modify it for debugging purposes to this:

Code: Select all

<!-- BEGIN profile_fields -->
<!-- IF profile_fields.IDENT eq 'firstname' -->
   <b>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</b>
<!-- ELSEIF profile_fields.IDENT eq 'lastname' -->
   <i>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</i>
<!-- ELSE -->
   <br/>My field name is "{profile_fields.IDENT}", my content is "{profile_fields.FIELD}".
<!-- ENDIF -->
<!-- END profile_fields -->
...so unrecognized fields will show up also. Have you also cleared the template cache?
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Pope94/IA
Registered User
Posts: 21
Joined: Sun Jan 16, 2011 4:45 pm

Re: Customize UCP fields

Post by Pope94/IA » Fri Feb 11, 2011 1:37 pm

That code does show fields but instead of just showing the bow and arrows field it shows every custom field that I have.

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Fri Feb 11, 2011 3:45 pm

That was the intention, since you now can see each IDENT of them which you previously failed to name right.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Pope94/IA
Registered User
Posts: 21
Joined: Sun Jan 16, 2011 4:45 pm

Re: Customize UCP fields

Post by Pope94/IA » Sat Feb 12, 2011 8:11 pm

AmigoJack wrote:That was the intention, since you now can see each IDENT of them which you previously failed to name right.
I dont want it to show every one though. I want a code so I can show each field individually. So my bow field will have its own code differant from my arrows field.... like the memberlist_view.html

In my memberlist_view.html I have something like this...

Code: Select all

<!-- IF S_PROFILE_BOW -->
				<tr>
					<td class="gen" align="right">{PROFILE_BOW_NAME}: </td>
					<td><b class="genmed">&nbsp;{PROFILE_BOW_VALUE}</b></td>
				</tr>
			<!-- ENDIF -->
<!-- IF S_PROFILE_ARROWS -->
				<tr>
					<td class="gen" align="right">{PROFILE_ARROWS_NAME}: </td>
					<td><b class="genmed">&nbsp;{PROFILE_ARROWS_VALUE}</b></td>
				</tr>
			<!-- ENDIF -->
See how putting BOW or ARROWS in there will change which custom field is shows?
I want to move this over to the user control panel so it will show each field individually.

So maybe it would use IF statements to show each one seperate?

My whole goal of this is to place my custom profile fields at differant places in the User Control Panel. For example.. I would have my bow field at the very top of the page... and my arrows field at the very bottom of the page. I want them seperate.

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Mon Feb 14, 2011 7:08 am

I understood that - and if the IDENTs of your fields are BOW and ARROW (the names are case sensitive) your code should look like this:

Code: Select all

<!-- BEGIN profile_fields -->
<!-- IF profile_fields.IDENT eq 'BOW' -->
   <b>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</b>
<!-- ELSEIF profile_fields.IDENT eq 'ARROW' -->
   <i>{profile_fields.LANG_NAME} = {profile_fields.FIELD}</i>
<!-- ELSE -->
   <br/>My field name is "{profile_fields.IDENT}", my content is "{profile_fields.FIELD}" and you need to give me another IF/ELSEIF branch in your code.
<!-- ENDIF -->
<!-- END profile_fields -->
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Tue Mar 01, 2011 1:23 pm

(to do this in the public profile, see this topic)
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Jackanape
Registered User
Posts: 1076
Joined: Wed Oct 13, 2004 6:01 am
Location: Capitol of the Great State of New York
Name: Jack Drury
Contact:

Re: Customize UCP fields

Post by Jackanape » Thu Mar 28, 2013 12:40 pm

Thanks for this Code Jack! Using this, I was able to move TWO specific custom fields to the top of my USP profile page, and left the rest at the bottom. Here's what I put up top:

Code: Select all

<!-- BEGIN profile_fields -->
	<!-- IF profile_fields.IDENT eq 'ms_user_name_first' --> 
	<dl>
		<dt><label<!-- IF profile_fields.FIELD_ID --> for="{profile_fields.FIELD_ID}"<!-- ENDIF -->>{profile_fields.LANG_NAME}:<!-- IF profile_fields.S_REQUIRED --> *<!-- ENDIF --></label>
		<!-- IF profile_fields.LANG_EXPLAIN --><br /><span>{profile_fields.LANG_EXPLAIN}</span><!-- ENDIF --></dt>
		<!-- IF profile_fields.ERROR --><dd class="error">{profile_fields.ERROR}</dd><!-- ENDIF -->
		<dd>{profile_fields.FIELD}</dd>
	</dl>
	<!-- ENDIF -->
	<!-- IF profile_fields.IDENT eq 'ms_user_name_last' --> 
	<dl>
		<dt><label<!-- IF profile_fields.FIELD_ID --> for="{profile_fields.FIELD_ID}"<!-- ENDIF -->>{profile_fields.LANG_NAME}:<!-- IF profile_fields.S_REQUIRED --> *<!-- ENDIF --></label>
		<!-- IF profile_fields.LANG_EXPLAIN --><br /><span>{profile_fields.LANG_EXPLAIN}</span><!-- ENDIF --></dt>
		<!-- IF profile_fields.ERROR --><dd class="error">{profile_fields.ERROR}</dd><!-- ENDIF -->
		<dd>{profile_fields.FIELD}</dd>
	</dl>
	<!-- ENDIF -->
	<!-- END profile_fields -->
and at the bottom:

Code: Select all

<!-- BEGIN profile_fields -->
		<!-- IF profile_fields.IDENT != 'ms_user_name_first' --> 
		<!-- IF profile_fields.IDENT != 'ms_user_name_last' --> 
		<dl>
			<dt><label<!-- IF profile_fields.FIELD_ID --> for="{profile_fields.FIELD_ID}"<!-- ENDIF -->>{profile_fields.LANG_NAME}:<!-- IF profile_fields.S_REQUIRED --> *<!-- ENDIF --></label>
			<!-- IF profile_fields.LANG_EXPLAIN --><br /><span>{profile_fields.LANG_EXPLAIN}</span><!-- ENDIF --></dt>
			<!-- IF profile_fields.ERROR --><dd class="error">{profile_fields.ERROR}</dd><!-- ENDIF -->
			<dd>{profile_fields.FIELD}</dd>
		</dl>
		<!-- ENDIF --> <!-- ENDIF --> 
	<!-- END profile_fields -->
Cheers, and thanks again!
~Extending the rule of meticulous exactitude to exaspirating punctillio...still.~
Treat your phpBB like a member of the family--Update and MOD her by hand, with HTML-Kit
: : Wanna Talk Poker? : : Image : :

cedricthecat
Registered User
Posts: 212
Joined: Sun May 03, 2009 4:02 pm
Name: Dave

Re: Customize UCP fields

Post by cedricthecat » Wed Jan 14, 2015 11:17 pm

We had a need to do something drastic with our CPF's as we have so many that the standard Profile Page in the UCP was getting a little unweildy

So, using the advice in the Post 2 above, I was able to create new modules and set up these to carry a smaller number of the CPF's each. However, I have since found that, sadly, this principle of having separate modules for "batches" of CPF's (one per car) is flawed. Say you have 20 CPF's numbered 1 to 20, and set up four modules (one each for 1 to 5, 6 to 10 etc). Assuming you have data in all of these CPF's, and then change something in the first module, whilst it will successfully save these changes on submission, unfortunately it also sets all the other fields back to their default state!

So it looks like the submission is working OK, and I'm getting confirmation, it just seems as though if a CPF is not on the submitted form, then the system doesn't know how to handle it and thus returns it to default....

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Customize UCP fields

Post by AmigoJack » Thu Jan 15, 2015 6:19 am

cedricthecat wrote:it just seems as though if a CPF is not on the submitted form, then the system doesn't know how to handle it and thus returns it to default
Since /includes/functions_profile_fields.php:update_profile_field_data() only manipulates what $cp_data contains it's more likely your code has a flaw. Either provide a ZIP here or PM me one and I can make sure.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Locked

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