Various modifications for phpBB3jQ Username BBCode with Group Colours

Snippets for phpBB3
Previous topicNext topic
User avatar

Topic Author
dmzx
Founder
Founder
Magic user status: Offline
Posts: 5971
Joined: Jan 13th, '14, 20:45
    unknown unknown

jQ Username BBCode with Group Colours

Post by dmzx »

[BBCode] jQ Username BBCode with Group Colours
Instruction to install.

open posting.php
Find This may be a partial find and not the whole line

Code: Select all

page_footer();
Add before Add these lines on a new blank line before the preceding line(s) to find

Code: Select all

// Username [BBCode] / (c) 4seven / 2011
          $sql = "SELECT user_id, username, user_colour
             FROM " . USERS_TABLE . "
             WHERE user_type IN (" . USER_FOUNDER . ', ' . USER_NORMAL . ")
             ORDER BY username_clean";
          $result  = $db->sql_query($sql);
       
          while ($row = $db->sql_fetchrow($result)){

          $row['user_colour'] = (!empty($row['user_colour'])) ? $row['user_colour'] : '000000';
          $style_bold         = ($row['user_colour'] == '000000') ? 'normal' : 'bold';
          
          $template->assign_block_vars('username_bb', array(
          'USERNAME_BB_BOLD'  => $style_bold,      
          'USERNAME_BB_VALUE' => '|#' . $row['user_colour'] . '|' . $style_bold . '|'. $row['user_id'],
          'USERNAME_BB_USER'  => $row['username']));}
          $db->sql_freeresult($result);
          // Username [BBCode] / (c) 4seven / 2011


open styles/prosilver/template/posting_buttons.html
Find This may be a partial find and not the whole line

Code: Select all

<!-- BEGIN custom_tags -->
                <input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" />
        <!-- END custom_tags -->
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

<!-- IF not S_PRIVMSGS -->

        <script type="text/javascript">
        // <![CDATA[ 
        !window.jQuery && document.write('<script type="text\/javascript" src="http:\/\/code.jquery.com\/jquery.min.js"><\/script>');
        // ]]> 
        </script>

        <!-- Username [BBCode] / (c) 4seven / 2011 -->
        <select id="hide_username" style="font-size:11px;" title="Select Username">
        <option value="#" selected="selected" style="display: none">Select Username</option>
        <!-- BEGIN username_bb -->
        <option value="{username_bb.USERNAME_BB_VALUE}">{username_bb.USERNAME_BB_USER}</option>
        <!-- END username_bb -->
        </select>
        <input id="username_click" type="button" class="button2" onclick="username_copy();" value="Insert" />

        <script type="text/javascript">
        // <![CDATA[
        function username_copy(){
        var username_copy = '[username' + $('#hide_username').val() + ']'+ $('#hide_username option:selected').text() + '[/username]';
        document.forms['postform'].message.value += username_copy;
        document.forms['postform'].message.focus();
        return false;}
        // ]]>
        </script>
        <!-- Username [BBCode] / (c) 4seven / 2011 -->    

    <!-- ENDIF -->
Make a bbcode

BBCode usage

Code: Select all

 [username|{COLOR}|{IDENTIFIER}|{NUMBER}]{TEXT}[/username]
HTML replacement

Code: Select all

<a class="username-coloured" style="color:{COLOR};font-weight:{IDENTIFIER};" href="./memberlist.php?mode=viewprofile&u={NUMBER}">{TEXT}</a>


Help line

Code: Select all

nothing
Display on posting page

Code: Select all

no
clear all board- and browser-caches

If you want to insert the content always at caret position and not at the end of the text,

change

Code: Select all

<script type="text/javascript">
        // <![CDATA[
        function username_copy(){
        var username_copy = '[username' + $('#hide_username').val() + ']'+ $('#hide_username option:selected').text() + '[/username]';
        document.forms['postform'].message.value += username_copy;
        document.forms['postform'].message.focus();
        return false;}
        // ]]>
        </script>
to

Code: Select all

<script type="text/javascript">
        // <![CDATA[
        function username_copy()
            {
                 insert_text('[username' + $('#hide_username').val() + ']'+ $('#hide_username option:selected').text() + '[/username]');
            }
        // ]]>
        </script>
clear all board- and browser-caches

Image
binance.com ;) try it!
User avatar

Topic Author
dmzx
Founder
Founder
Magic user status: Offline
Posts: 5971
Joined: Jan 13th, '14, 20:45
    unknown unknown

Re: jQ Username BBCode with Group Colours

Post by dmzx »

Delete the button and insert direct when selected.
Otherwise it is still possible to select 'Select Username'

Code: Select all

<!-- Username [BBCode] / (c) 4seven / 2011 -->
        <select id="hide_username" onchange="username_copy();" style="font-size:11px;" title="Select Username">
		<option value="#" selected="selected" style="display: none">Select Username</option>
        <!-- BEGIN username_bb -->
        <option value="{username_bb.USERNAME_BB_VALUE}">{username_bb.USERNAME_BB_USER}</option>
        <!-- END username_bb -->
        </select>
User avatar

TWEagle
Users
Users
Magic user status: Offline
Posts: 74
Joined: Nov 23rd, '14, 19:38
    Windows 8.1 Opera

Re: jQ Username BBCode with Group Colours

Post by TWEagle »

Testing this TWEagle
Image
User avatar

Topic Author
dmzx
Founder
Founder
Magic user status: Offline
Posts: 5971
Joined: Jan 13th, '14, 20:45
    Windows 8 Firefox

Re: jQ Username BBCode with Group Colours

Post by dmzx »

User avatar

Sniper_E
VIP
VIP
Magic user status: Offline
Posts: 1035
Joined: Oct 14th, '14, 17:01
    Windows 8.1 Firefox

Re: jQ Username BBCode with Group Colours

Post by Sniper_E »

Sniper_E thinks this is cool.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!™
Previous topicNext topic