The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Topic Prefix for phbb2

2 posters

Go down

Topic Prefix for phbb2 Empty Topic Prefix for phbb2

Post by Babybok November 4th 2016, 12:48 pm

Hello forumotion, just gonna ask if a phbb2 has a possibility to have a Topic Prefix? Cause I have already search some prefix related in here but the only forum version I see is phbb3,punbb and Invision. If there was a code for it can you post it here? I need your help guys and If it has, how can I modify it with a color?

Thanks in advance.

Edited:

I have search in the forum and saw this code for the prefix but it didn't function in my forum
Forum link: http://www.rl-rp.board.st
Forum Version: phbb2

Code:
var prefixes = ["PENDING", "ACCEPTED", "DENIED", "PENDING ADMIN", "PENDING INV", "APPROVED"];
var _pm = false;
 
var chk = false;
function toMenu(a) {
  var htmlpre = '<select style="margin-right:5px" id="prefix" size="1"><option value="">(None)</option>';
  for (i in a)
  htmlpre += '<option value="' + a[i] + '">' + a[i] + '</option>';
  htmlpre += '</select>';
  return htmlpre;
}
 
function checkpre(ar, input) {
  for (i in ar) {
      var p = new RegExp("" + ar[i], "g");
      var title = input.substr(0, input.indexOf(']'));
      if (p.test(title)) return ar[i];
  }
  return "";
}
$(function () {
  if (_pm) chk = /\privmsg/.test(location.href);
  if (/\/post/.test(location.href) || chk) {
      $(toMenu(prefixes)).insertBefore("input[name='subject'][type='text']");
      var mw = $("#prefix").width() + 5;
      $("input[name='subject']").css("width", $("input[name='subject']").width() - mw);
      var t = $("[name='subject']").val();
      var cur = checkpre(prefixes, t);
      if (cur != "") {
        $("[value=" + cur + "]").attr("selected", "selected");
        $("input[name='subject']").val(t.replace('[' + cur + ']', '').trim())
      }
      $("input[name='post']").click(function () {
        var sub = $("input[name='subject']").val().trim();
        if (sub != "" && $("#prefix").val() != "") $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
      })
  }
});


Last edited by Babybok on November 10th 2016, 3:37 pm; edited 5 times in total
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 5th 2016, 9:50 am

Bump! Can anyone help me? TIA
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 7th 2016, 3:51 am

Bump! Anyone please?
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Ch@lo Valdez November 10th 2016, 4:58 am

that code you posted, only works for add a prefix in the title when you create a new topic, you need this one.
Create a js new file into Administration panel, set it in all pages.

Code:

$.prefijos = function () {
    var i, a = document.querySelectorAll('a, h1,.postdetails'),
        copyright = 'Por Chalo, para http://www.opensourcephpbb3.com';
    for (i = 0; i < a.length; i++) {
        var b = a[i].innerHTML;
        if (/\[([^\[\]]+)\]/.test(b)) {
            var c = b.match(/\[(.*?)\]/)[1].toLowerCase().replace(/\W+/g, '-'),
                d = b.match(/\[(.*?)\]/)[1].toLowerCase(),
                e = b.replace(/^\[.*?\]/, '<span class="prefijo ' + c + '">' + d + '</span>');
            a[i].innerHTML = e
        }
    }
};
$(function () {
    $.prefijos()
});

This code replace all your prefix like this: [css], [solvet], etc, any word into the brackets works

then you need add a CSS this is the base
Code:
 
.prefijo {
 background: #ed7710;
  color: #FFF;
  border-radius: 2px;
  display: inline-table!important;
  line-height: 13px;
  padding: 1px 4px 0;
  font-weight: 700!important;
  font-size: 8px!important;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
  margin-left: 2px;
  font-family: arial;
}
all your prefix now are in orange, if you want have many colors need custom css for example
if you have a prefix [sports] needs add this in your css panel

Code:
.prefijo.sports{
background: red!important
}

[pets]
Code:
.prefijo.pets{
background: purple!important
}

etc, etc
you can see my demo here:
Spoiler:
Smile


Last edited by Ch@lo Valdez on November 10th 2016, 12:27 pm; edited 1 time in total
Ch@lo Valdez
Ch@lo Valdez
Forumember

Male Posts : 138
Reputation : 50
Language : spanish

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 10th 2016, 9:16 am

Hello @Ch@lo Valdez thanks for the help but is it for phpbb2 as well? and where to edit the brackets?

EDITED:
and If will put this into my js it never function but it replaces the log-out button to this


Topic Prefix for phbb2 Navbar10
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Ch@lo Valdez November 10th 2016, 12:23 pm

is fixed now:

Topic Prefix for phbb2 Captur10

please see my demo http://codelab.sitio-web.org/t25-soccer-ok-test#715 is phpbb2
in your forum have in the index a prefix [ch]

Topic Prefix for phbb2 Captur11

so, we have there .
Code:
.prefijo.ch
custom color comes if you add in your css .
Code:
.prefijo.ch{background:green!important}
and ...

Topic Prefix for phbb2 Captur12
Ch@lo Valdez
Ch@lo Valdez
Forumember

Male Posts : 138
Reputation : 50
Language : spanish

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 10th 2016, 1:17 pm

Thanks @Ch@lo Valdez it worked perfectl However the text didn't capitalize. Is there any ways to capitaliz the text?

Edited: oh It's ok now, I've change the toLowerCase to toUpperCase.

And one thing mate the prefix doesn't appear in the topic, I mean when you click into the topic the title just show up with this " [NOTICE] Blablahblah" Without the style.
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Ch@lo Valdez November 10th 2016, 2:12 pm

Babybok wrote:Thanks @Ch@lo Valdez it worked perfectl However the text didn't capitalize. Is there any ways to capitaliz the text?

Edited: oh It's ok now, I've change the toLowerCase to toUpperCase.

And one thing mate the prefix doesn't appear in the topic, I mean when you click into the topic the title just show up with this " [NOTICE] Blablahblah" Without the style.

please put again toLowerCase is for this reason you don`t get styles in your prefix, don't change anything

in css
Code:
.prefijo{ add text-transform: lowercase or uppercase
, capitalize is not possible;
Ch@lo Valdez
Ch@lo Valdez
Forumember

Male Posts : 138
Reputation : 50
Language : spanish

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 10th 2016, 2:33 pm

Ch@lo Valdez wrote:
Babybok wrote:Thanks @Ch@lo Valdez it worked perfectl However the text didn't capitalize. Is there any ways to capitaliz the text?

Edited: oh It's ok now, I've change the toLowerCase to toUpperCase.

And one thing mate the prefix doesn't appear in the topic, I mean when you click into the topic the title just show up with this " [NOTICE] Blablahblah" Without the style.

please put again toLowerCase is for this reason you don`t get styles in your prefix, don't change anything

in css
Code:
.prefijo{ add text-transform: lowercase or uppercase
, capitalize is not possible;

It's all good now, with the text, the only problem I have now is the style in the topic section,the style doesn't work.

Topic Prefix for phbb2 Img_2210
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Ch@lo Valdez November 10th 2016, 3:08 pm

please try with this:

Code:

$.prefijos = function () {
    var i, a = document.querySelectorAll('a:not(#logout), h1,.postdetails,.cattitle'),
        copyright = 'written by Chalo  http://www.opensourcephpbb3.com';
    for (i = 0; i < a.length; i++) {
        var b = a[i].innerHTML;
        if (/\[([^\[\]]+)\]/.test(b)) {
            var c = b.match(/\[(.*?)\]/)[1].toLowerCase().replace(/\W+/g, '-'),
                d = b.match(/\[(.*?)\]/)[1].toLowerCase(),
                e = b.replace(/\[.*?\]/, '<span class="prefijo ' + c + '">' + d + '</span>');
            a[i].innerHTML = e
        }
    }
};
$(function () {
    $.prefijos()
});
Ch@lo Valdez
Ch@lo Valdez
Forumember

Male Posts : 138
Reputation : 50
Language : spanish

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 10th 2016, 3:15 pm

Ch@lo Valdez wrote:please try with this:

Code:

$.prefijos = function () {
    var i, a = document.querySelectorAll('a:not(#logout), h1,.postdetails,.cattitle'),
        copyright = 'written by Chalo  http://www.opensourcephpbb3.com';
    for (i = 0; i < a.length; i++) {
        var b = a[i].innerHTML;
        if (/\[([^\[\]]+)\]/.test(b)) {
            var c = b.match(/\[(.*?)\]/)[1].toLowerCase().replace(/\W+/g, '-'),
                d = b.match(/\[(.*?)\]/)[1].toLowerCase(),
                e = b.replace(/\[.*?\]/, '<span class="prefijo ' + c + '">' + d + '</span>');
            a[i].innerHTML = e
        }
    }
};
$(function () {
    $.prefijos()
});

Nice job, thanks for all the help. A thanked for you is so worth it. Thanks man.

And yeah just wanna ask this time. Is it a even possible to have diffent prefixes in different forum? Like example : [Banned] prefix can be only use in Forum1 Section and [Accepted] prefix can only be use in Forum2 section.

Is that even possible @Ch@lo Valdez

Cancelling the solve, just want to complete my problem..
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Babybok November 12th 2016, 3:58 pm

@Ch@lo Valdez I ned you here man...
Babybok
Babybok
Forumember

Male Posts : 199
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Topic Prefix for phbb2 Empty Re: Topic Prefix for phbb2

Post by Ch@lo Valdez November 12th 2016, 8:33 pm

My code is global, it works looking for square brackets transforming them into html, with this code is not possible do that you want sorry
Ch@lo Valdez
Ch@lo Valdez
Forumember

Male Posts : 138
Reputation : 50
Language : spanish

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum