vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=229)
-   -   Show Thread Enhancements - Close / Open Thread Via Quick Reply (https://vborg.vbsupport.ru/showthread.php?t=180239)

Viper007Bond 05-22-2008 10:00 PM

Close / Open Thread Via Quick Reply
 
I wanted to be able to close and open threads as I left my reply via the quick reply box, so I wrote this little template mod.

https://vborg.vbsupport.ru/attachmen...4&d=1211542516


Features
  • Checkbox at the bottom of the quick reply box to toggle the current status. Only shows up for people with proper permissions.
  • Javascript is used to update the reply buttons (to change them from "Reply" to "Closed" and visa-versa).
  • Javascript is used to change the text next to the checkbox saying what will happen when you reply.

Installation


It's a fairly easy install and only requires editing one template (SHOWTHREAD), and importing a product (for the language phrases). The following instructions are for the default theme, but custom themes will probably be really similiar.

Download and install the product. This will create the new language phrases so you can translate this hack to your liking.

Then open up "SHOWTHREAD" and find this code. It's for the top reply button.

HTML Code:

        <if condition="$show['largereplybutton']">
                <td class="smallfont"><a href="newreply.php?$session[sessionurl]do=newreply&amp;noquote=1&amp;p=$FIRSTPOSTID" rel="nofollow"><if condition="$show['closethread']"><img src="$stylevar[imgdir_button]/reply.gif" alt="$vbphrase[reply]" border="0" /><else /><img src="$stylevar[imgdir_button]/threadclosed.gif" alt="$vbphrase[closed_thread]" border="0" /></if></a></td>
        <else />


You will need to give both the open (reply.gif) and the closed (threadclosed.gif) <img> tags a new CSS class called "replybutton" so that the Javascript can update them.

So for the default theme, that would result in this:

HTML Code:

        <if condition="$show['largereplybutton']">
                <td class="smallfont"><a href="newreply.php?$session[sessionurl]do=newreply&amp;noquote=1&amp;p=$FIRSTPOSTID" rel="nofollow"><if condition="$show['closethread']"><img src="$stylevar[imgdir_button]/reply.gif" alt="$vbphrase[reply]" border="0" class="replybutton" /><else /><img src="$stylevar[imgdir_button]/threadclosed.gif" alt="$vbphrase[closed_thread]" border="0" class="replybutton" /></if></a></td>
        <else />


Now do the same thing for the bottom reply button (same HTML).


Now we need to add the new code to the bottom of the quick reply box (same template).

Find this code which is the HTML for the "quote message in post" checkbox:

HTML Code:

                                                        <label for="qr_quickreply"><input type="checkbox" name="quickreply" value="1" id="qr_quickreply" accesskey="w" tabindex="4" />$vbphrase[quote_message_in_reply]</label>
                                                </div>
                                        </fieldset>


After that (and before what is probably a </div>), add all of this:

HTML Code:

<if condition="$show['openclose']">
                                        <fieldset class="fieldset" style="margin:$stylevar[formspacer]px 0px 0px 0px">
                                                <legend>$vbphrase[viper_opencloseqr_thread_management]</legend>
                                                <div style="padding:3px">
                                                        <div>
                                                                <label for="cb_openclose"><input type="checkbox" name="openclose" value="1" id="cb_openclose" tabindex="1" /><span id="qr_openclosestatus"><if condition="$show['closethread']">$vbphrase[viper_opencloseqr_close_thread]<else />$vbphrase[viper_opencloseqr_open_thread]</if></span></label>
                                                        </div>
                                                </div>
                                        </fieldset>

                                        <script type="text/javascript">
                                        /* <![CDATA[ */

                                                // Current thread status recorder
                                                var viperThreadOpen = <if condition="$show['closethread']">
true<else />false</if>;

                                                // Run the custom function when the quick reply form is submitted
                                                YAHOO.util.Event.addListener(document.getElementById("qrform"), "submit", viperQuikyReply);

                                                // Do some stuff when the form is submitted
                                                function viperQuikyReply() {

                                                        var viperOpenCloseCheckbox = document.getElementById("cb_openclose");
                                                        var viperQRTextareaChars = document.getElementById("vB_Editor_QR_textarea").value.length;
                                                        var viperReplyButtonIMG;

                                                        // If the checkbox wasn't checked or the message was too short (simple check), abort
                                                        if ( viperOpenCloseCheckbox.checked == false || viperQRTextareaChars == 0 || viperQRTextareaChars < $vboptions[postminchars] ) return;

                                                        // Uncheck the checkbox
                                                        viperOpenCloseCheckbox.checked = false;

                                                        // Change the text and set the reply button image filename
                                                        if ( viperThreadOpen == true ) {
                                                                document.getElementById("qr_openclosestatus").innerHTML = "$vbphrase[viper_opencloseqr_open_thread]";
                                                                viperReplyButtonIMG = "threadclosed.gif";
                                                                viperThreadOpen = false;
                                                        } else {
                                                                document.getElementById("qr_openclosestatus").innerHTML = "$vbphrase[viper_opencloseqr_close_thread]";
                                                                viperReplyButtonIMG = "reply.gif";
                                                                viperThreadOpen = true;
                                                        }

                                                        // Get all reply buttons via the new class
                                                        var replybuttons = YAHOO.util.Dom.getElementsByClassName("replybutton", "img");

                                                        // Loop through each reply button and change it's image URL
                                                        var i;
                                                        for (i in replybuttons) {
                                                                replybuttons[i].src = "$stylevar[imgdir_button]/" + viperReplyButtonIMG;
                                                        }
                                                }

                                        /* ]]> */
                                        </script>
</if>


Save and you're all done!


Oh, and don't forget to mark this as installed! :)

choccyclaire 05-23-2008 11:49 AM

I'm assuming only usergroups capable of closing and opening threads can see this option? :unsure:

Viper007Bond 05-23-2008 01:34 PM

Quote:

Originally Posted by choccyclaire (Post 1528872)
I'm assuming only usergroups capable of closing and opening threads can see this option? :unsure:

Yep. It uses the same test that vB uses for whether to display the close/open option in the Thread Tools dropdown.

Hornstar 05-23-2008 09:28 PM

Thanks, I remember this being available in the 3.0.x days and it is good to see it back.

choccyclaire 05-24-2008 11:37 AM

Quote:

Originally Posted by Viper007Bond (Post 1528965)
Yep. It uses the same test that vB uses for whether to display the close/open option in the Thread Tools dropdown.

Wicked stuff. Installed thanks! :up:

Allan 05-24-2008 01:36 PM

very practical I find, installed ;)

Magnumutz 05-24-2008 03:36 PM

Thanks, it does what it says :)
Installed.

Big Boss 05-24-2008 03:39 PM

Thank you for this!

Allan 05-25-2008 09:09 AM

Don't work for me ...

EDIT: Work ^^

Viper007Bond 05-25-2008 09:16 AM

I've minorly updated the hack. If your forum is in English, no need to update as all this update adds is easier translating of it. There are no other changes.

For those not using English, here's the changed lines:
  1. The "Thread Management" string has been replaced by "$vbphrase[viper_opencloseqr_thread_management]".

  2. The checkbox, it's label, etc. has been replaced with this line (replace the line with this new line):

    HTML Code:

    <label for="cb_openclose"><input type="checkbox" name="openclose" value="1" id="cb_openclose" tabindex="1" /><span id="qr_openclosestatus"><if condition="$show['closethread']">$vbphrase[viper_opencloseqr_close_thread]<else />$vbphrase[viper_opencloseqr_open_thread]</if></span></label>

  3. Code:

    document.getElementById("qr_openclosestatus").innerHTML = "Open";

    has been replaced with:

    Code:

    document.getElementById("qr_openclosestatus").innerHTML = "$vbphrase[viper_opencloseqr_open_thread]";

  4. Code:

    document.getElementById("qr_openclosestatus").innerHTML = "Close";

    has been replaced with:

    Code:

    document.getElementById("qr_openclosestatus").innerHTML = "$vbphrase[viper_opencloseqr_close_thread]";


Then just import the product now attached to the original post and the the new phrases will be created. They can be found under "Show Thread" and are prefixed with "viper_opencloseqr_".

Magnumutz 05-25-2008 09:57 AM

Ok... so i installed this thing yesterday, when it only had template edits... now do i have to install the product as well?

Ben E Lou 05-25-2008 04:50 PM

How about the ability to stick and unstick in Quick Reply as well?

Boofo 05-25-2008 05:03 PM

How about a text file with the instructions in case it ever needs to be re-installed?

Viper007Bond 05-26-2008 08:27 AM

Quote:

Originally Posted by Magnumutz (Post 1530785)
Ok... so i installed this thing yesterday, when it only had template edits... now do i have to install the product as well?

Make the template changes described in my above post (it's the differences between my original hack posting and the current hack posting) and then import the product to create the translation phrases. That's all the product is -- no plugins, hooks, or anything.

Quote:

Originally Posted by Ben E Lou (Post 1531083)
How about the ability to stick and unstick in Quick Reply as well?

Sure, why not. :)

Quote:

Originally Posted by Boofo (Post 1531106)
How about a text file with the instructions in case it ever needs to be re-installed?

Can't just visit this page or copy/paste?

I'll make one anyway though. :)

Magnumutz 05-26-2008 10:55 AM

Unfortunately, it looks that your product is not letting me completely use the quick reply.

Instead of showing my message after i post something... it doesn't show.

Viper007Bond 05-31-2008 02:18 AM

Quote:

Originally Posted by Magnumutz (Post 1531712)
Unfortunately, it looks that your product is not letting me completely use the quick reply.

Instead of showing my message after i post something... it doesn't show.

Odd. You sure you modified the template correctly?

Magnumutz 05-31-2008 05:45 AM

Yes, i'm positive... however, i've got the older version installed on another board and it works perfect.
Could i get the instructions to the older installation? :D

Viper007Bond 05-31-2008 09:21 AM

Quote:

Originally Posted by Magnumutz (Post 1536818)
Yes, i'm positive... however, i've got the older version installed on another board and it works perfect.
Could i get the instructions to the older installation? :D

Older as in the one I originally posted here? It's the same thing as now, it just had hardcoded text in English.

Although if you're talking about the VERY original code from months ago, that can be found here: https://vborg.vbsupport.ru/showthread.php?t=142968

Midnightfs 06-15-2008 08:13 AM

Fantastic! THANKS!

C138 Kaysone 07-03-2008 04:04 AM

this is a bit difficult for me, need help

C138 Kaysone 07-07-2008 07:09 AM

i need help installing this

Hurricane 10-15-2008 01:44 PM

Installed and working great on 3.7.3

The only thing I want to comment on is the install instructions tell you to modify the button for the top and bottom, but the code is slightly different.

When searching the text, one button is labeled $FIRSTPOSTID and the other $LASTPOSTID

So when doing the second reply button, look for:

Code:

<if condition="$show['largereplybutton']">
                <td class="smallfont"><a href="newreply.php?$session[sessionurl]do=newreply&amp;noquote=1&amp;p=$LASTPOSTID" rel="nofollow"><if condition="$show['closethread']"><img src="$stylevar[imgdir_button]/reply.gif" alt="$vbphrase[reply]" border="0" /><else /><img src="$stylevar[imgdir_button]/threadclosed.gif" alt="$vbphrase[closed_thread]" border="0" /></if></a></td>
        <else />

Just a little bump in the road.

Stoebi 01-17-2009 02:15 AM

Nice addon, thank you. :) Only a cosmetic bug I've found.

If I open or close the thread via quick reply, hover your mouse over the largereplybutton please (without a refresh).

If the thread is closed, you did not see the text 'Closed Thread'. You'll see 'Reply'. The alt="$vphrase['reply']" tag is used instead alt="$vbphrase['closed_thread'].

Any idea how can we fix this?


Regards, Stoebi


All times are GMT. The time now is 06:16 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01338 seconds
  • Memory Usage 1,829KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (5)bbcode_html_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete