Floris
19th February 2005, 07:23 AM
[HowTo][306] Forumhome "Who's Online" as end-user option
This quick tutorial will show you how to add a new custom profile field which can be used to allow the registered members to display (or not) an element like the users currently online.
First step: Make a new custom profile field.
Admin Control Panel > User Profile Fields > Add New User Profile Field
Profile Field Type > Single-Selection Menu
Title: Display Who's Online?
Description: Select "yes" will display the users currently online on the forum home.
Options: (each entry on a new line)
yes
no
Set default: Yes, but no first blank option.
Display Order: (whatever the entry is)
Field Required: No
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: no
Section > Optional input (you can leave this alone, should be no)
Section > Display Page >
Which page displays this option: options: other
Press [save] button.
Now it will load the user profile fields manager page.
Find the new show whos online custom profile field and remember which fieldid it has: I will use example: field5
Now the second step, updating the template.
Admin Control Panel > Styles & Templates > Style Manager > DropDown: Edit Templates.
Expand the group for Forum Home Templates Group > Select the template FORUMHOME and open it.
Find this code:<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
Replace it with this code:<if condition="$bbuserinfo['field5'] == 'yes'">
<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
</if>
And save the template.
You're basicly done now .. make sure you replace field5 with the fieldid you had to remember earlier, like field12 or field6. And also make sure your vBulletin Options > Show users currently online is set to yes. Otherwise the default is no, and then it won't ever show.
By default it will now show the who's online on forumhome, if a user doesn't want that part to show up, he or she should go to the user control panel > options > other options > and select NO to the question 'show whos online?' .
This quick tutorial will show you how to add a new custom profile field which can be used to allow the registered members to display (or not) an element like the users currently online.
First step: Make a new custom profile field.
Admin Control Panel > User Profile Fields > Add New User Profile Field
Profile Field Type > Single-Selection Menu
Title: Display Who's Online?
Description: Select "yes" will display the users currently online on the forum home.
Options: (each entry on a new line)
yes
no
Set default: Yes, but no first blank option.
Display Order: (whatever the entry is)
Field Required: No
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: no
Section > Optional input (you can leave this alone, should be no)
Section > Display Page >
Which page displays this option: options: other
Press [save] button.
Now it will load the user profile fields manager page.
Find the new show whos online custom profile field and remember which fieldid it has: I will use example: field5
Now the second step, updating the template.
Admin Control Panel > Styles & Templates > Style Manager > DropDown: Edit Templates.
Expand the group for Forum Home Templates Group > Select the template FORUMHOME and open it.
Find this code:<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
Replace it with this code:<if condition="$bbuserinfo['field5'] == 'yes'">
<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
</if>
And save the template.
You're basicly done now .. make sure you replace field5 with the fieldid you had to remember earlier, like field12 or field6. And also make sure your vBulletin Options > Show users currently online is set to yes. Otherwise the default is no, and then it won't ever show.
By default it will now show the who's online on forumhome, if a user doesn't want that part to show up, he or she should go to the user control panel > options > other options > and select NO to the question 'show whos online?' .