The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Show similar results when posting a new topic?

View previous topic View next topic Go down

Solved Show similar results when posting a new topic?

Post by Des M on November 21st 2014, 12:36 am

Hi,

When posting a new topic, is there a way to display search results for similar topics?

Example below submitted by one of our users.

Before typing any title:


After typing a title:


Last edited by Des M on November 21st 2014, 10:49 pm; edited 1 time in total

Des M
New Member

Posts : 19
Reputation : 1
Language : English
Location : Ireland

http://www.honda-haven.com

Back to top Go down

Solved Re: Show similar results when posting a new topic?

Post by Ange Tuteur on November 21st 2014, 1:12 am

Hello Des M,

I wrote up a quick prototype. See if this works :
( This is for version phpbb3 )

Go to Administration Panel > Modules > JavaScript codes management

Make sure javascript codes management is enabled and create a new script.

Title : Your choice
Placement : In all the pages
Paste the code below and submit :
Code:
/\?f=\d+&mode=newtopic/.test(window.location.search) && $(function() {
  var s = document.getElementsByTagName('INPUT'),i;
  for (i=0; i<s.length; i++) {
    if (/subject/.test(s[i].name)) {
      var d = document.createElement('DIV');
      d.innerHTML = '<div class="h3">Similar Topics</div><div id="topicSimilar">No similar topics..</div>';
      s[i].parentNode.appendChild(d);
      s[i].onkeyup = function() {
        if (this.value.length > 3) $('#topicSimilar').load('/search?search_keywords='+encodeURIComponent(this.value)+' a.topictitle', function() {
          $(this).find('a').attr({'target' : '_blank', 'style' : 'display:block'});
        });
        else $('#topicSimilar').html('No similar topics..');
      }
    }
  }
});

It'll only run on creation of a new topic. Each time you type a word over 3 characters it will send a query to the search page and load the topic titles with those keywords.

Example :
avatar
Ange Tuteur
Forumaster

Male Posts : 13176
Reputation : 2879
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Show similar results when posting a new topic?

Post by Des M on November 21st 2014, 10:48 pm

Excellent stuff, that appears to be working Very Happy

Thank you salut

Des M
New Member

Posts : 19
Reputation : 1
Language : English
Location : Ireland

http://www.honda-haven.com

Back to top Go down

Solved Re: Show similar results when posting a new topic?

Post by Ange Tuteur on November 21st 2014, 11:03 pm

You're welcome

Topic archived

If you have any problems don't hesitate to open a new topic. Smile
avatar
Ange Tuteur
Forumaster

Male Posts : 13176
Reputation : 2879
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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