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 Fri Nov 21 2014, 01:36

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 Fri Nov 21 2014, 23:49; 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 Fri Nov 21 2014, 02:12

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 :

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Des M on Fri Nov 21 2014, 23:48

Excellent stuff, that appears to be workingVery Happy

Thank yousalut

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 Sat Nov 22 2014, 00:03

You're welcome

Topic archived

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

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

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