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.

Make quoted author name clickable in quotes

5 posters

Go down

Make quoted author name clickable in quotes Empty Make quoted author name clickable in quotes

Post by Niko Sat Jun 03 2023, 14:09

Coucou,

another quick resource that may be useful for someone Razz

Introduction and Demo

The resource allows you to make the quoted author username clickable inside quotes. When you cite a previous post, the name of the author will become clickable!

From regular non-clickable quoted author
Make quoted author name clickable in quotes Scree144

to clickable author name
Make quoted author name clickable in quotes Scree145

Disclaimer

In the past, Pinguino (French Administrator) pointed out that the option was not included in the Forumotion update because of technical reasons. Please note that if you have too many quotes in the page, the loading may be slow - but otherwise don't worry about using this script! Very Happy
Pinguino wrote:Hello,

From memory, this integration caused a technical problem which motivated its withdrawal. The tech team just told me that this makes the pages load considerably longer.

Installation: Javascript

You need to go towards Administration Control Panel (ACP)   Modules HTML & Javascript Javascript codes management and create a new code - upon verifying that Javascript codes management is enabled.

  • Title: free choice - does not influence the code effect
  • Where: All pages
  • Code:
    Code:
    $(function() {
        
       /*
       Title: Make quoted author name clickable in quotes
       Author: Niko
       Version: 1.0
       Release Date: 03.06.2023 (dd.mm.year)
       Contact: https://www.fmcodes.net/u2
       Original content: https://www.fmcodes.net/t2037-
       */

        
       const FORUM_VERSION = _userdata["tpl_used"];

       var breadcrumb_quoteAuthor = {
          'subsilver': 'dl.codebox dt span.genmed b', //phpbb2
          'prosilver': 'blockquote div cite', //phpbb3
          'punbb': 'blockquote div cite', //punBB
          'invision': 'blockquote div cite', //invision
          'modernbb': 'blockquote div cite', //modernBB
          'awesomebb': 'blockquote cite' //awesomeBB
       };

        var wrote_keyword = $(breadcrumb_quoteAuthor[FORUM_VERSION]).text().split(' ').pop().split(':')[0];

       $(breadcrumb_quoteAuthor[FORUM_VERSION]).each(function(){
            var username = $(this).text().split(' '+wrote_keyword+':')[0];
            var textNode = $(this);
            
            $.ajax({
                  url: '/memberlist?username='+username,
                  type: 'GET',
                  success: function(data){
                        if(FORUM_VERSION == 'invision') {
                            var href = $(data).find(".membername span strong:contains('"+username+"')").parents('.member-header.clearfix').find('.popupmenu.clearfix ul li a[href*="/u"]').attr('href');
                            console.log(href);
                        } else {
                            var href = $(data).find("a span strong:contains('"+username+"'), a span:contains('"+username+"')").parents('a').attr('href');
                        }
                        var user_id = href.split('/u').pop()[0];
                          textNode.html(textNode.html().replace(username,'<a href="/u'+user_id+'" class="quote_mention_username">'+username+'</a>'));
                  }
            });
        });
    })


CSS

There is no required CSS to be included, but the clickable quoted username can be customized with this class
Code:
.quote_mention_username

Hope you will enjoy :wouhou: :wouhou:
Niko
Niko
Helper
Helper

Male Posts : 3110
Reputation : 245
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

YoshiGM, SarkZKalie, TonnyKamper and Razor12345 like this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by skouliki Sat Jun 03 2023, 14:33

nice trick Very Happy
skouliki
skouliki
Manager
Manager

Female Posts : 15161
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Niko likes this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by Niko Sat Jun 03 2023, 14:52

Thanks @skouliki ♥
Niko
Niko
Helper
Helper

Male Posts : 3110
Reputation : 245
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by TonnyKamper Sat Jun 03 2023, 17:07

Very nice @Niko
TonnyKamper
TonnyKamper
Active Poster

Female Posts : 1050
Reputation : 78
Language : Dutch/English
Location : DSF Admin

http://www.nederlandheelt.nl/forum

Niko likes this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by YoshiGM Sat Jun 03 2023, 17:38

Very useful!
Great job Niko Very Happy
YoshiGM
YoshiGM
Active Poster

Male Posts : 1501
Reputation : 144
Language : Spanish & English
Location : Mexico

http://asistencia.foroactivo.com/u21373

Niko likes this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by Niko Sat Jun 03 2023, 19:33

Thank you @TonnyKamper and @YoshiGM Flowers Flowers
Niko
Niko
Helper
Helper

Male Posts : 3110
Reputation : 245
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

TonnyKamper likes this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by chattigre Sun Jun 04 2023, 15:18

Hello,

Really ? One AJAX request per quote tag ?
Yes, there isn't, I think, any other way to achieve that. But imagine you display 50 posts per page, and each post on the page contains 2 quotes. Result : 100 AJAX requests affraid

Having this link can be very handy, of course, and we had it automatically on server side at a time, but it has been removed due to a too important server charge which was slowing down page loading. And this problem was on sever side, with PHP code and certainly only one single SQL request / loop to recover usernames links...
Your script do the same, but with separated individual AJAX request on server side, moreover AJAX requests that load a full HTML page and not only a single line of JSON data (because no choice, again)...

Thinking about time, client ressources and data needed to add these links, I'm not sure that this code have a very good cost/effect balance... Wink
I think it may consistently slow down topics pages...

Have a good day.
chattigre
chattigre
Forumember

Male Posts : 56
Reputation : 15
Language : French (10/10), English (5/10)
Location : French support forum

https://test1-chattigre.forumactif.com

Niko and TonnyKamper like this post

Back to top Go down

Make quoted author name clickable in quotes Empty Re: Make quoted author name clickable in quotes

Post by Niko Sun Jun 04 2023, 15:24

Coucou @chattigre

yeah, sadly I know Embarassed
I placed a disclaimer because of this, but I agree with you that it is not the best solution - so it needs to be used carefully

Niko wrote:

Disclaimer

In the past, Pinguino (French Administrator) pointed out that the option was not included in the Forumotion update because of technical reasons. Please note that if you have too many quotes in the page, the loading may be slow - but otherwise don't worry about using this script! Very Happy
Pinguino wrote:Hello,

From memory, this integration caused a technical problem which motivated its withdrawal. The tech team just told me that this makes the pages load considerably longer.

A possible "middle-way" could be to cache the username-userID retrieve, so that the "disaster" happens only once Embarassed

I agree with you also on the cost/effect balance - but it's upon the user's choice and decision huhohi huhohi
Of course, this resource will stay in the Community Coding and Analysis Zone, and will never turn into an official tutorial beu

but hey, here is the idea - maybe another user will get a better way to do it based on this idea Hello
Niko
Niko
Helper
Helper

Male Posts : 3110
Reputation : 245
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

TonnyKamper likes this post

Back to top Go down

Back to top

- Similar topics

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