1
#1
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 5th 2012, 11:18pm
This example will give you the ability to add a second rank to each post profile, and optionally, allow the member to set their own custom rank. The new rank will be below the current rank, but it can easily be moved to above the current rank. And if you want, the new rank can replace the current rank.

This is a particularly useful technique to know, because it demonstrates how to use javascript to convert one board feature (user profiles) into something completely different (ranks). There are several GREAT enhancements that are possible with this technique if you can think outside the box!

As always, please respect my copyright -- do not post this code anywhere, nor give it to anyone else! And as always, there will be no phpBB2 version because I don't support garbage. In addition, please do not ask about a PunBB version, because I will not be writing one. However, I would be thrilled if a member modified the script to work on PunBB boards, and posted the modified script as a reply in this topic!

Here's how to add this feature:

First, go to ACP>Users&Groups>Profiles and click on the "+" sign at the bottom right to add a new profile field. Select the following options:

Type: Text Field
Name: Custom Rank (It must be EXACTLY this name!!!)
Color: Leave blank!
Description: Whatever you want
URL Icon: Leave blank!
Necessarily Filled: No
Display: Profile AND Messages
Display Type: Text
Modify: Moderators, and members if you want members to set their own custom ranks
Display: Guests or Members, your choice
Separator: Horizontal Bar

Set the maximum length to whatever you want. Please note that you CANNOT change these settings unless I said it was OK to do so above! The script depends on several of these settings in order to work.

Once you have this filled out, click Save and make sure the "Custom Rank" field is at the top of the list. It MUST be at the top, or the script will not work!

Next, place the following code in a javascript file set to "In all the pages". It can be in its own file, or you can add it to the bottom of a javascript file you have already created.

var CopyrightNotice = 'User-Selectable ranks for forumotion phpBB3 and IPB2/Invision boards. Copyright © 2012 by Dion Designs. All Rights Reserved. Personal use and/or modification of this script is allowed, provided this entire copyright notice remains in the original or modified script. Distribution is not allowed without written consent from Dion Designs.';
$(function() {
var x=$('.postprofile').get();
for (i=0; i<x.length; i++) {
var y=x[i].getElementsByTagName('HR')[0];
if (y) {
y=y.previousSibling.previousSibling;
var rank=y.nextSibling.nodeValue;
if (rank.substring(0,1)==' ') {rank=rank.substring(1);}
if (y.innerHTML=='Custom Rank: ') {
var z=x[i].getElementsByTagName('DD')[0];
z.className='rankbox';
z.innerHTML+='<div class="customrank">' + rank + '</div>';
y.parentNode.removeChild(y.nextSibling.nextSibling);
y.parentNode.removeChild(y.nextSibling);
y.parentNode.removeChild(y);
}
}
}
});

And finally, if you want to format the new rank, you can do so with the following CSS:

.customrank {your CSS here}

That's it! You will now have a new profile field called "Custom Rank", and whatever you put in that field will show up as a rank. If the member already has a rank, the custom rank will be displayed below the "official" rank.

This gives you a lot of flexibility in setting up ranks for members. You can now have post-based ranks AND custom ranks like "Administrator". Or you can keep your current ranks and let members have some fun!



Here are two enhancements to this feature:

If you want the new rank above the current rank, find this line in the script:

$(z).append('<div class="customrank">' + rank + '</div>');

and change it to:

$(z).prepend('<div class="customrank">' + rank + '</div>');

If you want the custom rank to replace the current rank instead of being a second rank, find this line in the script:

$(z).append('<div class="customrank">' + rank + '</div>');

and change it to:

z.innerHTML='<div class="customrank">' + rank + '</div>';
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 6th 2012, 4:31pm
You won't write a PunBB version friend request notification (I know LGforum did just saying)
You won't write a PunBB version for this what's going on D:
φ
Posts: 71
Joined: October 14th 2011, 11:00pm
Location: CompuTalks
Likes Given: 1
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 6th 2012, 10:22pm
he almost never write for punbb or phpbb2 Image
maybe this topic will answer you why: Why Invision? Aren't templates the best way to make a great-looking board?
φ
Posts: 16
Joined: October 28th 2011, 11:00pm
Location: Greece
Likes Given: 3
1
#4
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 12:11am
Actually most of the examples here have PunBB versions. And this example would be very easy to modify to work on PunBB boards.

However...

I'm tired of finding my work posted on boards where my copyrights have been removed, and in several cases, the board owners have inserted their own copyrights and state they are the author. I've reported more than two dozen such boards through litigation in the past six months, but ALL are still around. And yet, OnlineGuardian (which is eToxic, NOT a separate company, and was formerly run by "Typlo") just banned the TSNF test board. The F'n TEST BOARD, where membership was closed and only the portal was visible! So my problems here and on TSNF a couple weeks ago were no accident. It was a message.

I've known for a long time that eToxic condones ripping because it's good for their business, even though it hurts the very people who have helped their business grow. I put up with it anyway because I was enjoying writing code that people could use (or abuse), and I had the time to do so. But neither are the case today. So this example (which is a rewritten version of something I posted here in a private forum last August) will be my last for the forseeable future. I can no longer tolerate having crap like the above happen to me, and also find my code with replaced copyrights posted as tutorials on an Arabic board, one where I was told that Amir/Godfather was a member.

I'll still be around to answer questions, and I have every intention to write a few more essays along the lines of what was referenced above. I'm also happy to write code to help people with a specific problem. But the days of my writing full-blown tutorials/examples are most likely over.

There are a number of outstanding coders here on forumotion, and I hope that one of them also has the software design skills to be able to step up and fill my shoes.

I will be opening a new forum here in the next few days. It will be called Website Design/Development. My goal for that forum will be to help people move beyond forumotion and into the real world. It will contain information (and code!) to help you start your own website, blog, and/or bulletin board.

And in the future (best guess right now, late April), I will be opening a WordPress blog and a stock phpBB3 board where these topics will be taken to a different level.

Finally, I have a number of old scripts that I wrote as tests/prototypes. I'll be adding them to the General Javascript Questions forum, and access to that forum will be restricted to those members who have access to it TODAY. I hope that the membership will find some use for them...
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 6:37am
those are sad news dion but you are right .. i'm waityng to see your blog and your phpbb3 board because i always wanted to learn how to do things on phpbb3 ..so looking forward to see your new projects
φ
Posts: 42
Joined: October 11th 2011, 11:00pm
Likes Given: 13
Likes Received: 1
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 10:00am
Dion said:
I will be opening a new forum here in the next few days. It will be called Website Design/Development. My goal for that forum will be to help people move beyond forumotion and into the real world. It will contain information (and code!) to help you start your own website, blog, and/or bulletin board.


this is really nice, Im new to this and what i want to learn is programming and coding and your forum have help me because I dont just copy paste the codes I try to understand why you wrote it the way you did.
so i hope your new forum will help me/us much more!

and i believe even when some retard ppl steal your codes + change the copyright, but also
there are ppl who want/need help and i guess it worth the time to help them.
φ
Posts: 16
Joined: October 28th 2011, 11:00pm
Location: Greece
Likes Given: 3
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 2:07pm
@Garland:
he has got time...& you will learn a lot
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 2:13pm
@Dion:
Dion said:
I will be opening a new forum here in the next few days. It will be called Website Design/Development. My goal for that forum will be to help people move beyond forumotion and into the real world. It will contain information (and code!) to help you start your own website, blog, and/or bulletin board.

And in the future (best guess right now, late April), I will be opening a WordPress blog and a stock phpBB3 board where these topics will be taken to a different level.

this is to me one of the greatest news :)
I will be following you at every step because a person who is moderating vBulletin gets readily irked by FM & its limitations ...& I have explained to you also.
As far as i can recall you were to write some essays about SEO techniques for FM & other relates issues, I am waiting for them


But plz plz vBulletin not but your writings about phpbb3 forums will be much more appreciated
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
Example 18: User-Selectable Ranks (IPB2/Invision, phpBB3)
Posted February 7th 2012, 3:06pm
what about forum that all about making and looking after a server becasue when i move away from forumotion i had to get an VPS hosting becasue normal hosting couldn't handle the traffic i was getting which cost around £380 per year.
φ
Posts: 29
Joined: December 17th 2011, 12:00am

Who is online

Users browsing this forum: No registered users and 0 guests