Latest topics
» bloquer un membre
by berlingo Yesterday at 18:19

» IconSkouliki Graphics
by skouliki Yesterday at 03:54

» [IN PROGRESS] Can this code work on pun version
by skouliki Thu 16 Nov 2017, 03:50

» Auto-suggest @mentions as You Type
by skouliki Wed 15 Nov 2017, 14:56

» [TUTORIAL] [ALL VERSIONS] Warning before posting
by demon99 Wed 15 Nov 2017, 08:12

» [HELP] About Profile Cover Code
by omarpop23 Tue 14 Nov 2017, 12:35

» About Add Reply & New Topic button (popup form)
by omarpop23 Mon 13 Nov 2017, 20:31

» Hello everyone this is Adam from France
by Adam Mon 13 Nov 2017, 13:32

» Add a login popup for the toolbar
by Ape Sun 12 Nov 2017, 18:41

» Post a message automatically when locking a topic
by ThunderTB Sun 12 Nov 2017, 13:51

» Control pannel issue
by Ange Tuteur Sun 12 Nov 2017, 09:49

» BUG... forum members birthday's
by Ape Sat 11 Nov 2017, 11:44

» Display a Preview of Groups on Hover
by ThunderTB Fri 10 Nov 2017, 21:56

» Search box only visible on hover
by Ange Tuteur Mon 06 Nov 2017, 09:57

» [GAME] Animal Game
by SLGray Sun 05 Nov 2017, 15:04

Recent Tutorials
Who is online?
In total there are 5 users online :: 0 Registered, 0 Hidden and 5 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

Widget : Similar topics

View previous topic View next topic Go down

avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Tue 19 Jan 2016, 15:41

This widget will display topics that contain similar keywords based on the topic you're currently viewing.


Click to view demo

This widget should work on any forum version.

Installation


To install this widget go to Modules > Forum widgets management and create a new widget with the following settings.

Widget name : Similar topics
Use a table type : Yes
Widget title : Similar topics
Widget source :
Code:
<style type="text/css">
#fa_topics_similar a {
  font-size:10px;
  font-weight:normal;
  display:block;
  padding:3px; 0;
}
 
#fa_topics_similar a b {
  font-weight:normal;
}
 
#fa_ts_more {
  text-align:center;
  font-weight:bold;
  margin-top:3px;
}
</style>
<div id="fa_topics_similar"></div>
<script type="text/javascript">//<![CDATA[
(function() {
  var amount = 5,
      lang = {
        see_more : 'View all similar topics',
        loading : 'Finding similar topics...',
        error_node : '<code>#fa_topics_similar</code> is null',
        error_version : 'Forum version could not be identified'
      },
 
      url = '/search?search_keywords=',
      node = document.getElementById('fa_topics_similar'),
      temp = document.createElement('DIV'),
      topics,
 
      hideModule = function(node) {
        switch (node.parentNode.tagName) {
          case 'TD' : // phpbb2
            jQuery(node).closest('.forumline').hide();
            break;
 
          case 'DIV' : // phpbb3, punbb, invision
            jQuery(node).closest('.module').hide();
            break;
 
          default :
            document.write('<p style="color:#F30;font-size:12px;">' + lang.error_version + '<p>');
            break;
        }
      };
 
  if (/\/t\d+/.test(window.location.href) && node) {
    url += encodeURIComponent(document.title.replace(/(.*?)(?:\s-\s.*)/, function(M, S) { return S }));
    node.innerHTML = lang.loading;
 
    jQuery.get(url + '&change_version=prosilver', function(d) {
      topics = jQuery('a.topictitle', d);
      node.innerHTML = '';
 
      if (topics[0]) {
 
        for (var i = 0, j = amount + 1; i < j; i++) {
          if (topics[i]) {
            topics[i].href = topics[i].href.replace(/\?.*/, '');
            if (!new RegExp(topics[i].href).test(window.location.href)) {
              jQuery('.coloradmin', topics[i]).removeAttr('style class');
              temp.appendChild(topics[i]);
            }
          }
        }
 
        node.appendChild(temp); 
      } else {
        hideModule(node);
      }
    });
    document.write('<div id="fa_ts_more"><a href="' + url + '">' + lang.see_more + '</a></div>');
  } else if (node) {
    hideModule(node);
  } else {
    document.write('<p style="color:#F30;font-size:12px;">' + lang.error_node + '<p>');
  }
}());
// par ange tuteur
//]]></script>
Question Example

When everything is setup correctly make sure to click "save" and drag the completed widget into the column you want it to show. After that the widget will show up while you're viewing a topic if there are any topics similar to it.

Notes


1. The widget will only show up while viewing topics and if there are any topics similar to it, otherwise it will remain hidden.
2. The topics are found by performing a search of the topic title keywords, and show the most recently updated topics.
3. By default 5 ( or less than 5 ) similar topics are displayed. You can change this by finding
Code:
amount = 5
and changing the "5" to any number you want.

If there are any problems or questions feel free to leave a response below. Enjoy ! Thumb right


Notice
Tutorial written by Ange Tuteur.
Reproduction not permitted without consent from the author.


Last edited by Ange Tuteur on Wed 20 Apr 2016, 12:33; edited 4 times in total
avatar
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 44
Posts : 2455
Points : 4769
Reputation : 287
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : ModernBB
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Sat 23 Jan 2016, 16:34

What will appear while looking at the index/homepage?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Sat 23 Jan 2016, 16:42

@SLGray wrote:What will appear while looking at the index/homepage?
I set a condition in place which will hide the widget when you're not viewing a topic. Thumb left
avatar
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 44
Posts : 2455
Points : 4769
Reputation : 287
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : ModernBB
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Sat 23 Jan 2016, 16:49

That is amazing.  Thanks for sharing this tutorial.
avatar
mist3r0us_b0y

Title :
Gender : Unspecified
Posts : 68
Points : 1640
Reputation : 16
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

Postmist3r0us_b0y on Mon 25 Jan 2016, 22:55

this is what we need thanks for sharing @Ange Tuteur

--------

avatar
ddr3
New Member
Title :
Gender : Unspecified
Posts : 4
Points : 1103
Reputation : 1
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

Postddr3 on Wed 17 Feb 2016, 18:07

In template (html) not working.

They can be added and the image of the subject?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Thu 18 Feb 2016, 07:27

@ddr3 wrote:In template (html) not working.
Which template are you adding it to ?

@ddr3 wrote:They can be added and the image of the subject?
I'm sorry, I did not comprehend. Could you try to explain this better ?
avatar
ddr3
New Member
Title :
Gender : Unspecified
Posts : 4
Points : 1103
Reputation : 1
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

Postddr3 on Sun 21 Feb 2016, 16:47

I'm sorry, I did not comprehend. Could you try to explain this better ?

example:



Which template are you adding it to ?

viewcomments_body instead widget
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Mon 22 Feb 2016, 13:12

I see what you mean. It's possible, however it'll require an unnecessary amount of AJAX to get the images for each topic. As for the template, I'm not sure why it isn't working. I'll have to look into it. reflect
avatar
ddr3
New Member
Title :
Gender : Unspecified
Posts : 4
Points : 1103
Reputation : 1
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

Postddr3 on Mon 22 Feb 2016, 14:43

Check to see what you can do.

Thank you.
avatar
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 44
Posts : 2455
Points : 4769
Reputation : 287
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : ModernBB
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Thu 14 Apr 2016, 23:32

I notice that the topic you are viewing is included in the similar topics widget.  Is there a way to stop that?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Fri 15 Apr 2016, 13:12

@SLGray wrote:I notice that the topic you are viewing is included in the similar topics widget.  Is there a way to stop that?
I didn't think about that !

Try replacing your widget with this updated one to see if it fixes that problem :
Code:
<style type="text/css">
#fa_topics_similar a {
  font-size:10px;
  font-weight:normal;
  display:block;
  padding:3px; 0;
}
 
#fa_topics_similar a b {
  font-weight:normal;
}
 
#fa_ts_more {
  text-align:center;
  font-weight:bold;
  margin-top:3px;
}
</style>
<div id="fa_topics_similar"></div>
<script type="text/javascript">//<![CDATA[
(function() {
  var amount = 5,
      lang = {
        see_more : 'View all similar topics',
        loading : 'Finding similar topics...',
        error_node : '<code>#fa_topics_similar</code> is null',
        error_version : 'Forum version could not be identified'
      },
   
      url = '/search?search_keywords=',
      node = document.getElementById('fa_topics_similar'),
      temp = document.createElement('DIV'),
      topics,
   
      hideModule = function(node) {
        switch (node.parentNode.tagName) {
          case 'TD' : // phpbb2
            jQuery(node).closest('.forumline').hide();
            break;
     
          case 'DIV' : // phpbb3, punbb, invision
            jQuery(node).closest('.module').hide();
            break;
     
          default :
            document.write('<p style="color:#F30;font-size:12px;">' + lang.error_version + '<p>');
            break;
        }
      };
   
  if (/\/t\d+/.test(window.location.href) && node) {
    url += encodeURIComponent(document.title.replace(/(.*?)(?:\s-\s.*)/, function(M, S) { return S }));
    node.innerHTML = lang.loading;
 
    jQuery.get(url + '&change_version=prosilver', function(d) {
      topics = jQuery('a.topictitle:lt(' + amount + ')', d);
      node.innerHTML = '';
   
      if (topics[0]) {
     
        for (var i = 0, j = topics.length; i < j; i++) {
          if (!new RegExp(window.location.href.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).test(topics[i].href)) {
            topics[i].href = topics[i].href.replace(/\?.*/, '');
            jQuery('.coloradmin', topics[i]).removeAttr('style class');
            temp.appendChild(topics[i]);
          }
        }
     
        node.appendChild(temp);     
      } else {
        hideModule(node);
      }
    });
    document.write('<div id="fa_ts_more"><a href="' + url + '">' + lang.see_more + '</a></div>');
  } else if (node) {
    hideModule(node);
  } else {
    document.write('<p style="color:#F30;font-size:12px;">' + lang.error_node + '<p>');
  }
}());
// par ange tuteur
//]]></script>
avatar
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 44
Posts : 2455
Points : 4769
Reputation : 287
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : ModernBB
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Fri 15 Apr 2016, 20:05

The topic is still appearing in the widget.
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Fri 15 Apr 2016, 20:18

@SLGray wrote:The topic is still appearing in the widget.
I found the problem ; I checked the URL before it was modified. I think I fixed it now, give this a try :
Code:
<style type="text/css">
#fa_topics_similar a {
  font-size:10px;
  font-weight:normal;
  display:block;
  padding:3px; 0;
}
 
#fa_topics_similar a b {
  font-weight:normal;
}
 
#fa_ts_more {
  text-align:center;
  font-weight:bold;
  margin-top:3px;
}
</style>
<div id="fa_topics_similar"></div>
<script type="text/javascript">//<![CDATA[
(function() {
  var amount = 5,
      lang = {
        see_more : 'View all similar topics',
        loading : 'Finding similar topics...',
        error_node : '<code>#fa_topics_similar</code> is null',
        error_version : 'Forum version could not be identified'
      },
 
      url = '/search?search_keywords=',
      node = document.getElementById('fa_topics_similar'),
      temp = document.createElement('DIV'),
      topics,
 
      hideModule = function(node) {
        switch (node.parentNode.tagName) {
          case 'TD' : // phpbb2
            jQuery(node).closest('.forumline').hide();
            break;
   
          case 'DIV' : // phpbb3, punbb, invision
            jQuery(node).closest('.module').hide();
            break;
   
          default :
            document.write('<p style="color:#F30;font-size:12px;">' + lang.error_version + '<p>');
            break;
        }
      };
 
  if (/\/t\d+/.test(window.location.href) && node) {
    url += encodeURIComponent(document.title.replace(/(.*?)(?:\s-\s.*)/, function(M, S) { return S }));
    node.innerHTML = lang.loading;
 
    jQuery.get(url + '&change_version=prosilver', function(d) {
      topics = jQuery('a.topictitle', d);
      node.innerHTML = '';
 
      if (topics[0]) {
   
        for (var i = 0, j = amount + 1; i < j; i++) {
          if (topics[i]) {
            topics[i].href = topics[i].href.replace(/\?.*/, '');
            if (!new RegExp(topics[i].href).test(window.location.href)) {
              jQuery('.coloradmin', topics[i]).removeAttr('style class');
              temp.appendChild(topics[i]);
            }
          }
        }
   
        node.appendChild(temp);   
      } else {
        hideModule(node);
      }
    });
    document.write('<div id="fa_ts_more"><a href="' + url + '">' + lang.see_more + '</a></div>');
  } else if (node) {
    hideModule(node);
  } else {
    document.write('<p style="color:#F30;font-size:12px;">' + lang.error_node + '<p>');
  }
}());
// par ange tuteur
//]]></script>
avatar
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 44
Posts : 2455
Points : 4769
Reputation : 287
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : ModernBB
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Fri 15 Apr 2016, 20:26

Work Perfectly!

Thanks for taking the time to give me the coding.
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9584
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Fri 15 Apr 2016, 20:30

Perfect ! I'll update the code in the first post. Wink

No problem, thanks for letting me know of this. Smile

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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