Custom Profile Fields - Ordering and Display
Posted: 31 Jul 2011, 00:51
Custom Profile Fields - Ordering and Display
Written by Stoker
Set the order and display of your Custom Profile Fields in Topic and Profile page.
With this guide you will learn how to:
Lets use this board as example. At this time we have 6 custom profile fields:
BBCodes
Favourite BBCode
Real Name (made as link to wikipedia)
Alias
MyInfo (placed next to the username - popup with highslide)
Kudo Rank (linked image to the users Ohloh profile. Only visible in the Profile)
Notice the names in bold. We will use them when displaying the custom profile field.
[center]Custom Profile Fields in topics[/center]
First we will find the code that makes all the custom profile fields in the topic.
Its found in viewtopic_body.html: Yes, that tiny piece of code is actually doing it all. And it is this we will make some changes to. It is that code we will replace.
To display the custom profile fields we will have to put them in beteen this:
BBCodes
This is the exact piece of code that outputs the BBCodes custom profile field:
So for displaying this single field we use this code: This will only show a single custom profile field. Lets add some more.
Favourite BBCode
This is the exact piece of code that outputs the Favourite BBCode custom profile field:
We will add this to our existing 1 custom profile field. We only have to add this part of the code:
Real Name
The 3. field we will add is a link to wikipedia. Its opening in a new window.
This is the exact code to display this custom profile field:
Now the final code to use will look like this:
Alias
The 4. field we will add is simple, we have done this before.
This is the exact code to display this custom profile field:
When this is added we will end up with this:
MyInfo
The 5. field is more exiting. We will place it next to the username and use the highslide script to show a popup with the custom profile field info.
This is NOT a guide how to use highslide, just an example
The code used the the Info field:
Because we are going to display this field another place, we have to wrap it in these tags:
So we will end up with this: and we will insert this on a new line after: Again, this is just an example. You can use it in another place.
Kudo Rank
This one is not displayed in the topics, so no code is added here.
[center]Custom Profile Fields in profiles[/center]
First we will find the code that makes all the custom profile fields in the profile.
Its found in memberlist_view.html:
This is only a little different from displaying the fields in the topics. Same procedure, but a little change in the code. This is the code we will replace.
BBCodes
The code used for this field is this:
To make it display the final code:
Favourite BBCode
The code used for this field is this:
To make it display with the 1. field, the final code is:
Real Name
Link to wikipedia, opens in new window
The code used for this field is this:
To make it display with the other fields, the final code is:
Alias
The code used for this field is this:
To make it display with the other fields, the final code is:
MyInfo
This custom profile is not displayed in the profile. So nothing is added.
Kudo Rank
A linked image to the users ohloh profile. Placed under the rank image.
The code used for this field is this: and because we are placing this another place, we have to wrap in in this:
So the final code to insert is:
To place it right under the rank image, add it after this code:
[center]Other examples[/center]
In this section I will add more examples as we go along.
YouTube Favourite
Lets add our YouTube Favourite, but only in profile.
First you need to create the custom profile field in ACP
Open styles/prosilver/template/memberlist_view.html
Find:
Before add:
Here you go, your favourite youtube video in your profile
Written by Stoker
Set the order and display of your Custom Profile Fields in Topic and Profile page.
With this guide you will learn how to:
- Set your custom profile fields in a specific order
- Use them as links
- Use them to display an image
- Define if you want display them in topic and/or profile
- Define where to show them in topic and profile
Lets use this board as example. At this time we have 6 custom profile fields:
BBCodes
Favourite BBCode
Real Name (made as link to wikipedia)
Alias
MyInfo (placed next to the username - popup with highslide)
Kudo Rank (linked image to the users Ohloh profile. Only visible in the Profile)
Notice the names in bold. We will use them when displaying the custom profile field.
[center]Custom Profile Fields in topics[/center]
First we will find the code that makes all the custom profile fields in the topic.
Its found in viewtopic_body.html:
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 -->
To display the custom profile fields we will have to put them in beteen this:
Code: Select all
<!-- BEGIN custom_fields -->
your custom profile fields here....
<!-- END custom_fields -->
BBCodes
This is the exact piece of code that outputs the BBCodes custom profile field:
Code: Select all
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "BBCodes" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "BBCodes" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
<!-- END custom_fields -->
Favourite BBCode
This is the exact piece of code that outputs the Favourite BBCode custom profile field:
Code: Select all
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Favourite BBCode" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
<!-- END custom_fields -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "BBCodes" -->
<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 "Favourite BBCode" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
<!-- END custom_fields -->
Real Name
The 3. field we will add is a link to wikipedia. Its opening in a new window.
This is the exact code to display this custom profile field:
Code: Select all
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Real Name" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> <a href="http://en.wikipedia.org/wiki/{postrow.custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{postrow.custom_fields.PROFILE_FIELD_VALUE}</a></dd>
<!-- ENDIF -->
<!-- END custom_fields -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "BBCodes" -->
<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 "Favourite BBCode" -->
<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 "Real Name" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> <a href="http://en.wikipedia.org/wiki/{postrow.custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{postrow.custom_fields.PROFILE_FIELD_VALUE}</a></dd>
<!-- ENDIF -->
<!-- END custom_fields -->
Alias
The 4. field we will add is simple, we have done this before.
This is the exact code to display this custom profile field:
Code: Select all
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Alias" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "BBCodes" -->
<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 "Favourite BBCode" -->
<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 "Real Name" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> <a href="http://en.wikipedia.org/wiki/{postrow.custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{postrow.custom_fields.PROFILE_FIELD_VALUE}</a></dd>
<!-- ENDIF -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "Alias" -->
<dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
<!-- ENDIF -->
<!-- END custom_fields -->
MyInfo
The 5. field is more exiting. We will place it next to the username and use the highslide script to show a popup with the custom profile field info.
This is NOT a guide how to use highslide, just an example
The code used the the Info field:
Code: Select all
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "MyInfo" -->
<span style="color: {postrow.POST_AUTHOR_COLOUR}"> | </span><a style="color: {postrow.POST_AUTHOR_COLOUR}" href="#" onclick="return hs.htmlExpand(this, { contentId: '{postrow.POST_AUTHOR}-{postrow.POST_ID}', slideshowGroup: '{postrow.POST_AUTHOR}', width: '400' } )" title="Info">Info</a>
<div class="highslide-maincontent" id="{postrow.POST_AUTHOR}-{postrow.POST_ID}">
<div class="highslide-header">
<ul>
<li class="highslide-move">
<a href="#" onclick="return false">Move</a>
</li>
<li class="highslide-close">
<a href="#" onclick="return hs.close(this)">Close</a>
</li>
</ul>
</div>
<div><hr /><table border="0" width="100%">
<tr>
<td><!-- IF postrow.POSTER_AVATAR -->
<a href="{postrow.U_PROFILE}">{postrow.POSTER_AVATAR}</a>
<!-- ELSE -->
<a href="{postrow.U_PROFILE}"><img src="{T_THEME_PATH}/images/no_avatar.gif" width="90" height="90" alt="Default Avatar" /></a>
<!-- ENDIF --></td>
<td style="text-align: center; width:100%;"><!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->{postrow.RANK_IMG}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF --><b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="font-size:12px; color: {postrow.POST_AUTHOR_COLOUR}" <!-- ENDIF -->>{postrow.RANK_TITLE}</b><!-- ENDIF -->
</td><td valign="top" style="text-align: right;">{postrow.ONLINE_IMG}</td>
</tr>
</table><hr />
<b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="color: {postrow.POST_AUTHOR_COLOUR}" <!-- ENDIF -->>{postrow.POST_AUTHOR} is saying:</b><br />
{postrow.custom_fields.PROFILE_FIELD_VALUE}</div>
</div>
<!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- END custom_fields -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME eq "MyInfo" -->
<span style="color: {postrow.POST_AUTHOR_COLOUR}"> | </span><a style="color: {postrow.POST_AUTHOR_COLOUR}" href="#" onclick="return hs.htmlExpand(this, { contentId: '{postrow.POST_AUTHOR}-{postrow.POST_ID}', slideshowGroup: '{postrow.POST_AUTHOR}', width: '400' } )" title="Info">Info</a>
<div class="highslide-maincontent" id="{postrow.POST_AUTHOR}-{postrow.POST_ID}">
<div class="highslide-header">
<ul>
<li class="highslide-move">
<a href="#" onclick="return false">Move</a>
</li>
<li class="highslide-close">
<a href="#" onclick="return hs.close(this)">Close</a>
</li>
</ul>
</div>
<div><hr /><table border="0" width="100%">
<tr>
<td><!-- IF postrow.POSTER_AVATAR -->
<a href="{postrow.U_PROFILE}">{postrow.POSTER_AVATAR}</a>
<!-- ELSE -->
<a href="{postrow.U_PROFILE}"><img src="{T_THEME_PATH}/images/no_avatar.gif" width="90" height="90" alt="Default Avatar" /></a>
<!-- ENDIF --></td>
<td style="text-align: center; width:100%;"><!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->{postrow.RANK_IMG}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF --><b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="font-size:12px; color: {postrow.POST_AUTHOR_COLOUR}" <!-- ENDIF -->>{postrow.RANK_TITLE}</b><!-- ENDIF -->
</td><td valign="top" style="text-align: right;">{postrow.ONLINE_IMG}</td>
</tr>
</table><hr />
<b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="color: {postrow.POST_AUTHOR_COLOUR}" <!-- ENDIF -->>{postrow.POST_AUTHOR} is saying:</b><br />
{postrow.custom_fields.PROFILE_FIELD_VALUE}</div>
</div>
<!-- ENDIF -->
<!-- END custom_fields -->
Code: Select all
<!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->
Kudo Rank
This one is not displayed in the topics, so no code is added here.
[center]Custom Profile Fields in profiles[/center]
First we will find the code that makes all the custom profile fields in the profile.
Its found in memberlist_view.html:
Code: Select all
<!-- BEGIN custom_fields --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- END custom_fields -->
BBCodes
The code used for this field is this:
Code: Select all
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "BBCodes" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "BBCodes" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- END custom_fields -->
Favourite BBCode
The code used for this field is this:
Code: Select all
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Favourite BBCode" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "BBCodes" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Favourite BBCode" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- END custom_fields -->
Real Name
Link to wikipedia, opens in new window
The code used for this field is this:
Code: Select all
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Real Name" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd><a href="http://en.wikipedia.org/wiki/{custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{custom_fields.PROFILE_FIELD_VALUE}</a></dd><!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "BBCodes" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Favourite BBCode" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Real Name" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd><a href="http://en.wikipedia.org/wiki/{custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{custom_fields.PROFILE_FIELD_VALUE}</a></dd><!-- ENDIF -->
<!-- END custom_fields -->
Alias
The code used for this field is this:
Code: Select all
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Alias" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "BBCodes" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Favourite BBCode" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Real Name" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd><a href="http://en.wikipedia.org/wiki/{custom_fields.PROFILE_FIELD_VALUE}" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">{custom_fields.PROFILE_FIELD_VALUE}</a></dd><!-- ENDIF -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Alias" --><dt>{custom_fields.PROFILE_FIELD_NAME}:</dt> <dd>{custom_fields.PROFILE_FIELD_VALUE}</dd><!-- ENDIF -->
<!-- END custom_fields -->
MyInfo
This custom profile is not displayed in the profile. So nothing is added.
Kudo Rank
A linked image to the users ohloh profile. Placed under the rank image.
The code used for this field is this:
Code: Select all
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Kudo Rank" --><br /><dd style="text-align: center;"><a href="https://www.ohloh.net/accounts/{postrow.custom_fields.PROFILE_FIELD_VALUE}?ref=Rank" title="{postrow.custom_fields.PROFILE_FIELD_NAME}"><img src="https://www.ohloh.net/accounts/{postrow.custom_fields.PROFILE_FIELD_VALUE}/widgets/account_detailed.gif" style="width:191px; height:35px;" alt="" /></a></dd><!-- ENDIF -->
Code: Select all
<!-- BEGIN custom_fields --><!-- END custom_fields -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "Kudo Rank" --><br /><dd style="text-align: center;"><a href="https://www.ohloh.net/accounts/{postrow.custom_fields.PROFILE_FIELD_VALUE}?ref=Rank" title="{postrow.custom_fields.PROFILE_FIELD_NAME}"><img src="https://www.ohloh.net/accounts/{postrow.custom_fields.PROFILE_FIELD_VALUE}/widgets/account_detailed.gif" style="width:191px; height:35px;" alt="" /></a></dd><!-- ENDIF -->
<!-- END custom_fields -->
Code: Select all
<!-- IF RANK_IMG --><dd style="text-align: center;">{RANK_IMG}</dd><!-- ENDIF -->
[center]Other examples[/center]
In this section I will add more examples as we go along.
YouTube Favourite
Lets add our YouTube Favourite, but only in profile.
First you need to create the custom profile field in ACP
Open styles/prosilver/template/memberlist_view.html
Find:
Code: Select all
<!-- IF SIGNATURE -->
Code: Select all
<!-- BEGIN custom_fields -->
<!-- IF custom_fields.PROFILE_FIELD_NAME eq "YouTube Favourite" -->
<div class="panel bg1">
<div class="inner"><span class="corners-top"><span></span></span>
<h3>{custom_fields.PROFILE_FIELD_NAME}</h3>
<div style="text-align:center;"><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/{custom_fields.PROFILE_FIELD_VALUE}"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/{custom_fields.PROFILE_FIELD_VALUE}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></div>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- ENDIF -->
<!-- END custom_fields -->