Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Slonarch on December 10, 2004, 03:16:59 PM

Title: Partial quoting and "to" button
Post by: Slonarch on December 10, 2004, 03:16:59 PM
Would it be possible to quote only a highlited part of the post, like it is done, for instance, here: http://forums.referat.ru/?board=server&action=display&s=0&num=1101201074 (sorry, I only know a russian forum with this feature. The button I am talking about is at the bottom of the user info section of the post, to the right from the button saying ">>имя:").

Well, since I already started the topic, the button saying ">>имя:" is also useful as it pastes a name of the person you are responding to to a quick reply box. Can this be done too?


How to do it!

- in script.js add:
function quote_selection()
{
selection = document.getSelection ? document.getSelection() : document.selection.createRange().text;
document.postmodify.message.value += '\n[quote]' + selection + '[/quote]\n';
}

function to_name(char_name)
{
document.postmodify.message.value += '[b][u]2 [color=red]' + char_name + '[/color][/u][/b]: ';
}


- in Display.template.php look for:
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';
add after:
echo '
<table><tr><td align="center" border="0">
<img src="', $settings['images_url'], '/author.gif" alt="Author" onclick="to_name(\'', $message['member']['name'], '\')" border="0" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td>
<td align="center" border="0">
<img src="', $settings['images_url'], '/quote1.gif" alt="Quote" onclick="quote_selection()" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td></tr></table> ';



[edit] added how to do it [/edit]
Title: Re: Partial quoting and "to" button
Post by: Peter Duggan on December 10, 2004, 05:49:29 PM
Quote from: Slonarch on December 10, 2004, 03:16:59 PM
Would it be possible to quote only a highlited part of the post, like it is done, for instance, here: http://forums.referat.ru/?board=server&action=display&s=0&num=1101201074 (sorry, I only know a russian forum with this feature. The button I am talking about is at the bottom of the user info section of the post, to the right from the button saying ">>имя:").

Assuming you already know you can delete what you don't want from the quote, split it into chunks, rearrange it and all that?

QuoteWell, since I already started the topic, the button saying ">>имя:" is also useful as it pastes a name of the person you are responding to to a quick reply box. Can this be done too?

Since neither of those buttons is doing anything for me, it's difficult to give a useful answer.
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 10, 2004, 07:49:58 PM
QuoteAssuming you already know you can delete what you don't want from the quote, split it into chunks, rearrange it and all that?
Have been using this feature for 3 years and now feel armless without it. It decreases your number of clicks in complicated quoting by 3-4 times. After moving our community to a SMF-powered forum, every single user asked me for it.

QuoteSince neither of those buttons is doing anything for me, it's difficult to give a useful answer.
Strange. Did you check the quick reply box after clicking ">>имя:"? It basically pastes something like 2Peter Duggan: in your quick reply box with one single click. Very convenient.
Title: Re: Partial quoting and "to" button
Post by: [Unknown] on December 10, 2004, 08:14:10 PM
That's a YaBB forum.  Looks like they've either installed some mod (which wouldn't be that difficult to port to SMF) or custom code.  However, the functionality doesn't seem at all to work with Firefox.

Slonarch, look at Peter Duggan's post.  Do you notice that he quotes you, and it says:
"Quote from: Slonarch on Today at 12:16:59 PM"

I may be reading you wrong, but that's what it sounds like you're asking for.  If you expand the quick reply box, and click "quote", this is what you get ;).  However, it won't just quote that text which you select... that's considerably more complicated.  And definitely browser dependent.

-[Unknown]
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 11, 2004, 09:28:35 AM
QuoteThat's a YaBB forum.  Looks like they've either installed some mod (which wouldn't be that difficult to port to SMF) or custom code.  However, the functionality doesn't seem at all to work with Firefox.
I am afraid they did it by themselves, but if I find a mod, will that help?

QuoteSlonarch, look at Peter Duggan's post.  Do you notice that he quotes you, and it says:
"Quote from: Slonarch on Today at 12:16:59 PM"
I did, but that button I mentioned would do it without quoting. Oftentimes you do not need to quote a person at all.

QuoteI may be reading you wrong, but that's what it sounds like you're asking for.  If you expand the quick reply box, and click "quote", this is what you get .  However, it won't just quote that text which you select... that's considerably more complicated.  And definitely browser dependent.
No, that is not exactly it. Assume you have a large smart post, and I disagree with 10 statements of yours. All I need to do with partial quoting is highlight and "partial quote" these 10 points, it will be done in 20 clicks, and my response will look very nice and structured :) Same result with usual quoting will require me to switch to a "post reply" mode and manually copy/paste the text and put tags around it (unless I get it all wrong :)), which is much harder.
Title: Re: Partial quoting and "to" button
Post by: Anguz on December 12, 2004, 04:59:41 AM
Hmm... let me see if I got this right. You want an automated way of splitting the post you're quoting into, let's say, it's paragraphs? Pretty much like what you just did with [Unknown]'s post?
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 12, 2004, 07:34:59 AM
2Anguz:
Yes, but not just paragraphs. Say I want to quote one single word from your post. I just highlight it with my mouse, click the button, and this word will be in my quick reply box within the "quote" tags.

An example of a discussion with the use of patial quoting (quotes are the grey text):
http://forums.ag.ru/?board=brehno&action=display&s=0&num=1094747302&start=25
Title: Re: Partial quoting and "to" button
Post by: Anguz on December 12, 2004, 07:56:01 AM
I see, in fact, just see, cause I couldn't read read anything. Can't try it cause seems I need to be logged in to try the partial quote, of course, I have no idea what I tried doing for sure either.

Honestly, if it's just to save a copy/paste and clicking on the quote button once, I don't think it's really needed. :P

Just curious, does it work with any browser or only IE?
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 12, 2004, 08:20:06 AM
QuoteHonestly, if it's just to save a copy/paste and clicking on the quote button once, I don't think it's really needed. :P
Well, that's a typical thought about any new feature in a design that you are used to :) Since most people do not have experience with it, it is a matter of believing me and other 20 users of my resourse that asked for it after they have been using it for several years. In fact, if this is not done here, I am willing to study PHP for implementing this single feature :)

QuoteJust curious, does it work with any browser or only IE?
AFAIK, in most browsers it does.
Title: Re: Partial quoting and "to" button
Post by: [Unknown] on December 12, 2004, 08:27:39 AM
This feature is mainly to do with JavaScript.  I don't believe it can even be done for Safari, but it's possible with other browsers - although some lose selection when you click, so it might have to handle onmousedown only.

PHP isn't really involved in this, actually.

-[Unknown]
Title: Re: Partial quoting and "to" button
Post by: Anguz on December 12, 2004, 08:39:32 AM
QuoteSince most people do not have experience with it, it is a matter of believing me and other 20 users of my resourse that asked for it after they have been using it for several years.

I know what you mean.
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 12, 2004, 05:43:37 PM
I alread found the script, just need to find out, how to paste it into this forum. It would simplify my life if sombedy told me how the variable containing the name of the user is called (in YaBB it is "$userprofile[1]") :)
Title: Re: Partial quoting and "to" button
Post by: Grudge on December 12, 2004, 06:40:17 PM
$user_info['name'] should have it
Title: Re: Partial quoting and "to" button
Post by: [Unknown] on December 12, 2004, 11:49:32 PM
Well, of the poster he probably means - which is $message['member']['name'].

-[Unknown]
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 18, 2004, 01:59:43 PM
Just got a chance to try this yesterday and was not able to paste the code right away :)

That's what I have, it is a code from YaBB:

This goes to Display.template.php under the IM icons:

<table><tr><td align="center" border="0">
                <img src="$pic/author.gif" alt="Author" onclick='javascript:to_name("$userprofile[1]")' style='cursor:hand'>
                </td>
                <td align="center" border="0">
                <img src="$pic/quote1.gif" alt="Quote" onclick='javascript:quote_selection()'  style='cursor:hand'></td></tr></table>


I already know that $userprofile[1] should be changed to $user_info['name'], but for some reason even this single line with to_name function screwed up the whole page (I think I do not know how to deal with quotes).

And this goes to a javascript file (script.js ?):

function quote_selection() {
selection = (document.getSelection) ? document.getSelection() : document.selection.createRange().text;
document.postmodify.message.value += ' [quote]' + selection + '[/quote] ';
}

function to_name(char_name) {
document.postmodify.message.value += '[b][u]2 [color=Red]' + char_name + '[/color][/u][/b]: ';


Here I need to know what to put instead of document.postmodify.message.value. Should I create an object in the quick response form and be changing it's value?
Title: Re: Partial quoting and "to" button
Post by: [Unknown] on December 19, 2004, 12:25:23 AM
I suggest:

<table><tr><td align="center" border="0">
                <a href="javscript:void(0);" onclick="to_name(\'', $message['member']['name'], '\'); return false;"><img src="', $settings['images_url'], '/author.gif" alt="Author" border="0" /></a>
                </td>
                <td align="center" border="0">
                <img src="', $settings['images_url'], '/quote1.gif" alt="Quote" onclick="quote_selection();" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" /></td></tr></table>

(cusor: hand is not very browser proof, and also onclick doesn't need the javascript: part.)

You can also add this to index.template.php, but assuming you want it in script.js, I suggest:

function quote_selection()
{
selection = document.getSelection ? document.getSelection() : document.selection.createRange().text;
document.postmodify.message.value += '\n[quote]' + selection + '[/quote]\n';
}

function to_name(char_name)
{
document.postmodify.message.value += '[b][u]2 [color=red]' + char_name + '[/color][/u][/b]: ';
}


In post and quick reply, it is document.postmodify.message... or should be.

-[Unknown]
Title: Re: Partial quoting and "to" button
Post by: Slonarch on December 19, 2004, 01:32:52 PM
Thank you from me and my community, this was the most important mod I ever installed! However, it did not work exactly the way you wrote it (there were extra quotation marks after quote_selection function and the to_name function did not work at all for some reason), I had do modify it slightly. The only bug I found so far is that Opera does not copy the selected text, but most people on my forum use IE anyway :)

That's what I came up with:

echo '
<table><tr><td align="center" border="0">
<img src="', $settings['images_url'], '/author.gif" alt="Author" onclick="to_name(\'', $message['member']['name'], '\')" border="0" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td>
<td align="center" border="0">
<img src="', $settings['images_url'], '/quote1.gif" alt="Quote" onclick="quote_selection()" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td></tr></table> ';

goes to Display.template.php under the line saying
                     <a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

I left Javascript the way you wrote it.

I urge everybody to try it, it is a VERY convenient feature :)
Title: Re: Partial quoting and "to" button
Post by: hfhs72 on January 15, 2005, 11:11:14 AM
Hi Guys,
I've been following this thread with great interest. I'm the webmaster for a new website for our old high school. We've been using the Delphi message forum for the past few years and have over 2000 users. We would like to switch everyone over to our new site and use SMF for our forum. Those of you familiar with Delphi know that it uses profile names in the To and From header which allows users to reply directly to someone. The reply window also provides a drop down box with a dozen or so recent users that you can select if you want to change the Reply To.

Complaints that I've had so far are that SMF's Reply does not put in who the reply message is for.

Example: FROM: John Smith
                TO:      John Doe

The TO: would have a drop down box attached to it, that would allow the replyer to change who the reply message is for. The drop down box would have a list of recent users and an ALL selection.

I'm new to this forum and hope I am explaining myself clearly to you guys who know how SMF works and can add this Mod or actually put it into the code. I would love to see it soon so we can switch to SMF and stop paying those outrages charges that Delphi Charges.

Here are some links to Delphi and our web site it you need to see it.

http://henryfordhighschool.com/smf/index.php

http://forums.delphiforums.com

Regards,

Don

Title: Re: Partial quoting and "to" button
Post by: hfhs72 on January 15, 2005, 11:20:40 AM
Sorry Guys,

I see I'm not suppose to put requests in this thread. I'll post this in the Request Topic.

Don
Title: Re: Partial quoting and "to" button
Post by: suren on January 17, 2005, 11:17:23 PM
how do make it so that the two new buttons (author & quote) are placed next to the normal quote button ??
Title: Re: Partial quoting and "to" button
Post by: [Unknown] on January 18, 2005, 02:51:42 AM
Add them in this area of the Display template:

<td align="right" valign="bottom" height="20" nowrap="nowrap" style="font-size: smaller;">';

-[Unknown]
Title: Re: Partial quoting and "to" button
Post by: suren on January 18, 2005, 05:55:48 AM
my implementation of the above code  ;)


Incrementing sellective quotation with member name.

in script.js go to the end , add:

// Incrementing sellective quotation with member name.
var index = 1;
var total = 0;

function quote_selection(char_name, post_date)
{
total += index;
selection = document.getSelection ? document.getSelection() : document.selection.createRange().text;
document.postmodify.message.value += '\n[quote author=' + char_name + ' ' + 'date=' + post_date + ']' + '[b][color=red]' + total + ' ' + '[/color][/b]: ' + selection + '[/quote]\n';
}

in Display.template.php , Find:

// Can they reply?  Have they turned on quick reply?
if ($context['can_reply'] && !empty($options['display_quick_reply']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" onclick="if (!currentSwap) doQuote(', $message['id'], '); else window.location.href = this.href; return false;">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/quote.gif" alt="' . $txt[145] . '" border="0" />' : $txt[145]), '</a>';
// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/quote.gif" alt="' . $txt[145] . '" border="0" />' : $txt[145]), '</a>';

add after:

// Incrementing sellective quotation with member name.
echo '
<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/quote.gif" alt="Sellective quotation" onclick="quote_selection(\'', $message['member']['name'], '\', \'', , '\')" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />';



as you can see there is one small unfinished part ( the second parameter to the function "posted date" is not there does any one know how i can get the post date in the correct format ???)
Title: Re: Partial quoting and "to" button
Post by: hfhs72 on January 18, 2005, 10:50:02 AM
Quote from: Slonarch on December 19, 2004, 01:32:52 PM

To Slonarch,

I've been trying to follow what you and [unknown] have done however, it's very confusing with so many messages. Can you post exactly what code has to go where and in what files so, us newbies can do this without messing up our boards.

Thanks,
Don
Title: Re: Partial quoting and "to" button
Post by: Slonarch on April 20, 2005, 02:37:17 PM
hfhs72,

Sorry, havn't been here for a while. Hope it will still be helpful.

echo '
<table><tr><td align="center" border="0">
<img src="', $settings['images_url'], '/author.gif" alt="Author" onclick="to_name(\'', $message['member']['name'], '\')" border="0" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td>
<td align="center" border="0">
<img src="', $settings['images_url'], '/quote1.gif" alt="Quote" onclick="quote_selection()" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td></tr></table> ';

goes to Display.template.php under the line saying
                     <a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

and


function quote_selection()
{
selection = document.getSelection ? document.getSelection() : document.selection.createRange().text;
document.postmodify.message.value += '\n[quote]' + selection + '[/quote]\n';
}

function to_name(char_name)
{
document.postmodify.message.value += '[b][u]2 [color=red]' + char_name + '[/color][/u][/b]: ';
}


goes to the bottom of script.js

You probably should try suren's code though.
Title: Re: Partial quoting and "to" button
Post by: kober on April 20, 2006, 10:41:57 AM
How to make it working with firefox 1.5? now it is not working :(
Title: Re: Partial quoting and "to" button
Post by: iv_nik on May 04, 2006, 04:22:12 AM
Quote from: Slonarch on December 12, 2004, 07:34:59 AMAn example of a discussion with the use of patial quoting (quotes are the grey text):
http://forums.ag.ru/?board=brehno&action=display&s=0&num=1094747302&start=25
In this example partial quoting DOES work with OPERA, when using code from this topic it doesn't work.
How to make Opera quote selected text?
Title: Re: Partial quoting and "to" button
Post by: iv_nik on May 11, 2006, 02:54:04 PM
Thanks to bANAn (http://metropolis.anthill.ru/forum/index.php?action=profile;u=86), now we have working version of partial quoting in Opera:
In display.template.php search
<a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['label'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . $message['member']['online']['label'] . '" border="0" />' : $message['member']['online']['label'], '</a>';
Add after it the following code:
        //Quote Selection
          echo '

<table><tr>
<td align="left" border="0">
<img src="', $settings['images_url'], '/quote_selection.gif" "' . $txt['quote_sel'] . '" title="' . $txt['quote_sel'] . '" onmouseover="copySelection()" style="cursor: ', $context['browser']['is_ie'] ? 'hand' : 'pointer', '" />
</td></tr></table>';


In script.js add: function copySelection()
{
  var text = null;
        w = window;
        if (w.document.getSelection) {
                text = (w.document.getSelection());
  } else if (w.getSelection) {
                text = (w.getSelection() /*.getRangeAt(0)*/);
        } else if (w.document.selection) {
                var selection = w.document.selection;
                text = selection.createRange().text;
        } else {
                return false;
        }
document.postmodify.message.value += '\n[quote]' + text + '[/quote]\n';
}


The only thing to mention: it's working on mouseover due particular selected text processing in Opera.

Tested on v.1.1RC2
Title: Re: Partial quoting and "to" button
Post by: Vinspire on May 14, 2006, 01:13:02 PM
Ermmm ... can i know what is this trick suppose to do ?

Kinda confused in the threads ....

Screenshot of what this trick did would be great  ;D ;D ;D
Title: Re: Partial quoting and "to" button
Post by: lodyr on May 14, 2006, 04:17:21 PM
How to make text references? How correctly to write?
<a href="javscript:void(0);" onclick="to_name(\'', $message['member']['name'], '\'); return false;" title="Author">Author</a>
correctly?                               
<a href="javscript:void(0);" onclick="quote_selection(); return false;" title="Quote">Quote</a>
or
<a href="javascript:quote_selection();" style="cursor: ', $context['browser']['is_ie'] ? 'pointer' : 'hand', '" title="Quote">Quote</a>
Title: Re: Partial quoting and "to" button
Post by: MothMan on December 19, 2006, 02:31:33 PM
Has anyone gotten this to work with the latest forum release (1.1.1) ?

I've tried every code changes suggested in the thread, and none of them are working for me...  they simply don't seem to make any change.  The new function is not present, the buttons do not appear, etc.
Title: Re: Partial quoting and "to" button
Post by: 4LP3RUZ1 on December 28, 2006, 05:07:57 AM
Quote from: MothMan on December 19, 2006, 02:31:33 PM
Has anyone gotten this to work with the latest forum release (1.1.1) ?

I've tried every code changes suggested in the thread, and none of them are working for me...  they simply don't seem to make any change.  The new function is not present, the buttons do not appear, etc.

I wrote a 1.1 implementation that only works with quick-reply in here (http://www.simplemachines.org/community/index.php?topic=137730.msg879148#msg879148)
Title: Re: Partial quoting and "to" button
Post by: BBC on August 03, 2010, 06:56:47 AM
This tweak generates lot of errors with validation:

style="cursor: pointer" />

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Title: Re: Partial quoting and "to" button
Post by: BBC on August 03, 2010, 06:57:42 AM
: 'pointer', '" />

So it is in Display.template.php
Title: Re: Partial quoting and "to" button
Post by: BBC on August 03, 2010, 07:03:42 AM
Well, stupid me. I put back alt="Quote" and alt="Author" and it is OK now.
Tooltip didn´t worked wit alt attribute and i deleted it and write title=.