View Full Version : Existing Topics Check
Velocd
01-08-2004, 10:00 PM
http://www.animesystem.com/temp/etc1-0.jpg
This hack will allow you and your members to check for existing topics, or similar ones, of the thread you plan to create when at newthread.php.
This should help to prevent double topics that often appear from newbish members who neglect to use the search feature.
It uses the exact functions as the "similar threads" feature, therefore has the same accuracy.
Tested to work on:
vBulletin 3 RC2
Internet Explorer 6 (with Javascript enabled)
Mozilla Firebird 0.7 / Mozilla 1.5 (with Javascript enabled)
------------------------------------------------
Tweak #1
If you would like the find icon to show upon typing in the input box, and then disappear if the input box is empty upon change, please do the following:
In the template newthread, find:
function showFind(object)
{
if(object.value != '')
{
document.findicon.src = "$stylevar[imgdir_button]/findicon_on.gif";
document.findicon.style.cursor = "pointer";
}
else
{
document.findicon.src = "$stylevar[imgdir_button]/findicon_off.gif";
document.findicon.style.cursor = "default";
}
}
Replace it with:
function showFind()
{
document.findicon.src = "$stylevar[imgdir_button]/findicon_on.gif";
document.findicon.style.cursor = "pointer";
}
function hideFind(object)
{
if(object.value == '')
{
document.findicon.src = "$stylevar[imgdir_button]/findicon_off.gif";
document.findicon.style.cursor = "default";
}
}
In the same template, find:
<td><input type="text" class="bginput" name="subject" onChange="showFind(this)" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
Replace it with:
<td><input type="text" class="bginput" name="subject" onchange="hideFind(object)" onkeypress="showFind()" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
------------------------------------------------
Attached is a screenshot.
Inside the zip are English, German, and French installation instructions. Please be aware I used a software translator for the German and French docs.
Enjoy. ;)
MrNase
01-09-2004, 10:26 AM
Hey very cool :)
albibak
01-09-2004, 12:56 PM
Thx Velocd for this hack.
I do the translation in french for vbulletin-fr.com and I join it on this post, because I see that you put in the zip file a speed translation by a software translator ;)
FleaBag
01-09-2004, 02:10 PM
Excellent idea and wonderfully executed. I think my users will appreciate this as much as I shall.
sabret00the
01-09-2004, 04:19 PM
great hack :)
NuclioN
01-09-2004, 04:44 PM
--edit-- forgot a template :) Works fine
Koutaru
01-09-2004, 07:13 PM
Thanks Velocd! :D
* Koutaru installs
Boofo
01-10-2004, 10:52 AM
I ran into a small problem with this. I have a thread titled:
Nesting conditional statements in templates
It did not find it when I tested for the exact same phrase or conditional statements, either one. And that thread was in the same forum.
Also, the button is off before you click it the first time. Shouldn't it be on so you know it is available to click (or am I missing something here)? ;)
Velocd
01-10-2004, 06:12 PM
It did not find it when I tested for the exact same phrase or conditional statements, either one. And that thread was in the same forum.
It uses the same functions as the smiilar threads feature, so if it's not finding it I'm not sure what to say.
Create two threads called "Nesting conditional statements in templates", go into one of them, and scroll to the bottom and see if the other thread shows up in the "similar threads" feature.
Also, the button is off before you click it the first time. Shouldn't it be on so you know it is available to click (or am I missing something here)?
There is an onchange Javascript behavior on the subject field, and when the subject field changes that icon becomes active. Otherwise, you don't want somebody clicking the button when the subject field is empty (although it would just give a Javascript alert box).
Boofo
01-10-2004, 06:33 PM
Shouldn't the icon become active when you type soemthing in there? It only becomes active here after I click it.
And yes the title shows up in the similar threads when there are 2 of them.
I never changed any of the default settings for the similar threads in the Admin CP. Do those need to be changed, too?
Dean C
01-10-2004, 06:57 PM
What a great idea! I'd love to see this installed here. :)
PranK
01-11-2004, 06:37 AM
nice work mate! Thanks.
/me clicks install
Christian
Velocd
01-11-2004, 04:14 PM
Shouldn't the icon become active when you type soemthing in there? It only becomes active here after I click it.
Ah ha!
Good point. I'll tweak it a bit, since that does seem more suitable.
And yes the title shows up in the similar threads when there are 2 of them.
Are both topics exactly (case-sensitive) the same? Maybe there is a case-sensitive problem in the hack.
I'll look into the code to see what could be causing the conflict of it not showing another of the same topic.
Edit:
Check out the attachment Boofo, I tested the topic on my localhost and it seems to work.
Boofo
01-11-2004, 04:20 PM
Thank you, sir. Let me know when you have something and I will be glad to test it out for you. I'm really looking forward to this hack. ;)
Yes, they are exactly the same in case-sensitivity. But it wouldn't even find a part of the title either (i.e. conditional statements). ;)
Boofo
01-11-2004, 04:22 PM
Ah ha!
Good point. I'll tweak it a bit, since that does seem more suitable.
Are both topics exactly (case-sensitive) the same? Maybe there is a case-sensitive problem in the hack.
I'll look into the code to see what could be causing the conflict of it not showing another of the same topic.
Edit:
Check out the attachment Boofo, I tested the topic on my localhost and it seems to work.
Could it be because they are in a private forum and passworded as to why it won't work here??
Velocd
01-11-2004, 04:40 PM
Yes, if you don't have permission to view the forum those threads are in, they wont show. Although I'm guessing you do have permission since you're the administrator.
For those wanting the suggestion (https://vborg.vbsupport.ru/showpost.php?p=460156&postcount=10) made by Boofo, I've added the instructions to the tweak in the first post. ;)
Boofo
01-11-2004, 04:42 PM
I don't have a lot of threads since I am starting from scratch so maybe it has to do with that then. I don't know. ;)
Boofo
01-11-2004, 04:47 PM
Have the instructions been updated to include this?
Velocd
01-11-2004, 04:50 PM
Have the instructions been updated to include this?
If you're referring to the tweak, no.
The tweak instructions are in the first post. ;)
buro9
01-14-2004, 07:56 PM
If you're referring to the tweak, no.
The tweak instructions are in the first post. ;)
I had a very similar thing running on my old VB2 forums, I have now installed this hack on my VB3 test site... and it's nice :) Very nice.
I have made a few adjustments though:
I've used document.getElementById() rather than use IE based document.all access. This will ensure compatibility with standards compliant browsers. You need to add id="" to the relevant pieces of HTML, subject and findicon I think are the only two.
I already added an onKeyUp alongside the onChange on the subject input box. This runs it everytime a key is lifted... though I left the onChange in there as it makes no difference and ensures that more limited browsers will still support it.
Aside from that... lovely hack :)
NTLDR
01-14-2004, 08:41 PM
I've used document.getElementById() rather than use IE based document.all access.
You should use fetch_object() (a vB JS function) this will give the best compatibility will all thr browsers vB supports properly.
Boofo
01-14-2004, 09:45 PM
The fix in the first post works great if you type it in, but if you paste something in the thread title, it doesn't turn on the button. Any fix for this? ;)
Boofo
02-16-2004, 01:28 AM
I'm getting a 406 error (object undefined) with this now after making the changes to the code in the first post. Any fix for this?
gmarik
02-22-2004, 07:04 AM
nice working ...
Boofo
02-22-2004, 03:54 PM
I had a very similar thing running on my old VB2 forums, I have now installed this hack on my VB3 test site... and it's nice :) Very nice.
I have made a few adjustments though:
I've used document.getElementById() rather than use IE based document.all access. This will ensure compatibility with standards compliant browsers. You need to add id="" to the relevant pieces of HTML, subject and findicon I think are the only two.
I already added an onKeyUp alongside the onChange on the subject input box. This runs it everytime a key is lifted... though I left the onChange in there as it makes no difference and ensures that more limited browsers will still support it.
Aside from that... lovely hack :)
Can you share the changes you made? ;)
buro9
02-22-2004, 06:55 PM
Can you share the changes you made? ;)
Yes, I hope this won't offend the hack creator... but here are snippets of my newthread template:
function showFind(element) {
if(element.value != '') {
document.getElementById('findicon').src = "$stylevar[imgdir_button]/findicon_on.gif";
document.getElementById('findicon').style.cursor = "pointer";
} else {
document.getElementById('findicon').src = "$stylevar[imgdir_button]/findicon_off.gif";
document.getElementById('findicon').style.cursor = "default";
}
}
<!-- subject field -->
<table cellpadding="0" cellspacing="0" border="0" class="fieldset">
<tr>
<td class="smallfont" colspan="3">$vbphrase[title]:</td>
</tr>
<tr>
<td><input type="text" class="bginput" name="subject" id="subject" onChange="showFind(this);" onKeyUp="showFind(this);" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
<td> </td>
<td><img id="findicon" name="findicon" src="$stylevar[imgdir_button]/findicon_off.gif" alt="Search for existing topics" onclick="openWindow()" /></td>
<td> </td>
<td><img id="display_posticon" src="$selectedicon[src]" alt="$selectedicon[alt]" /></td> </tr>
</table>
<!-- / subject field -->
Obviously I'm trusting that you can take the applicable small bits and merge them as appropriate into whatever you have.
Boofo
02-23-2004, 03:01 AM
How can you get this to show the button on when you start typing in the subject filed Box (like from tthe first post)?
buro9
02-23-2004, 04:26 AM
How can you get this to show the button on when you start typing in the subject filed Box (like from tthe first post)?
onKeyUp="showFind(this);"
From the first key it is activated.
Though a trim() function should be added to prevent it being activated on pressing of the space bar.
Boofo
02-23-2004, 05:19 AM
onKeyUp="showFind(this);"
From the first key it is activated.
Though a trim() function should be added to prevent it being activated on pressing of the space bar.
How do we add the trim code to this? ;)
Boofo
02-23-2004, 10:01 AM
Found a bug with this hack. If you have quotes in a thread title, you will get a javascript error when you click the button to check the topic and also the window will have the table in it without any topics. The title I used was:
"Killing all my chickens"
Any fix for this?
buro9
02-23-2004, 01:32 PM
How do we add the trim code to this? ;)
To add trim you'd do something like this:
function trim(str) {return str.replace(/^\s+/,'').replace(/\s+$/,'');}
function showFind(element) {
if(trim(element.value) != '') {
And then carry on as before.
As regards your quotes bug, it isn't apparent on my site using Firefox and IE6 to test with.
Boofo
02-23-2004, 01:41 PM
I get a line 7 expected ')' error when I use the quotes in a thread title. Isn't there a way to trim any code like that in the trim statement so it only looks for words? ;) I use IE 6, by the way. ;)
buro9
02-23-2004, 02:04 PM
I get a line 7 expected ')' error when I use the quotes in a thread title. Isn't there a way to trim any code like that in the trim statement so it only looks for words? ;) I use IE 6, by the way. ;)
I have just registered on your site and tested this, and I cannot generate an error.
I believe that the problem lies elsewhere... try CTRL+F5 to refreh your IE cache in case it has old files... and then look at any changes you've made to other JavaScript on the page (such as any hacks you've put into the vb supplied javascript).
I tested with "'` and all worked fine.
Line 7 also suggests something much higher in the file... maybe in one of the included files?
Cheers
David K
Boofo
02-23-2004, 02:21 PM
It only seems to happen when you use the quotes with a topic that doesn't exist. It the topic exists (like "testing") then I don't get the error. If I use "killing my chickens", I get the error. Does this make any sense?
buro9
02-23-2004, 05:42 PM
It only seems to happen when you use the quotes with a topic that doesn't exist. It the topic exists (like "testing") then I don't get the error. If I use "killing my chickens", I get the error. Does this make any sense?
Got it... it's here:
<script language="javascript">
window.alert("No matches found for:\n\""killing all chickens"\"");
window.close();
</script>
The double quotes aren't escaped in the javascript error message.
Boofo
02-23-2004, 05:46 PM
How do we fix that? ;)
buro9
02-23-2004, 05:47 PM
Got it... it's here:
<script language="javascript">
window.alert("No matches found for:\n\""killing all chickens"\"");
window.close();
</script>
The double quotes aren't escaped in the javascript error message.
Simple solution... in findtopic.php at the bottom, find:
eval('print_output("' . fetch_template('newthread_find') . '");');
Above it add:
if (empty($threads)) {
$subject = str_replace('"','\"',$subject);
}
Boofo
02-23-2004, 05:52 PM
You are a saint! Thank you, sir. That worked great! ;)
I'm glad it wasn't my imagination. ;)
Zilvia
03-25-2004, 06:50 PM
Does this work with the final release of vB 3.0.0?
Velocd
03-29-2004, 10:57 PM
Yes.
TheRayden
04-13-2004, 05:15 PM
Nice work. With the ammount of new people we usually receive this is going to be very usefull.
msimplay
05-09-2004, 11:25 AM
do i need automatic similar topics search on to use this ?
chrisvonc
05-09-2004, 10:17 PM
Velocd, working great! Thank you for releasing this hack. It was one of my favorites along with the similar topic hack for vB2.X and this helps greatly reduce the amount of double posting. I am suprised it was not added to v3. Looks to be working much stronger in vB3 than its earlier release.
As my site is geared toward non-technical people, there is a good chance a lot of them wont pick up on the search button so I just expanded the idea for the "on" gif from Tweak #1 to make it stand out a bit more for them once they typed their subject.
One thing I did notice, if you use the IE Auto-Complete feature, if you select something from one of it's entries, it doesnt toggle the search icon to ON. Not a big deal but if it can be fixed easily, I would certainly be interested in applying the fix.
Thanks again!
Chris
Eternal2u
05-24-2004, 04:15 AM
anything to give me an excuse to say them spamming +++++es knew there was a thread for there specific thread already...
Thanks...
**Clicks Install**
Nice hack Velocd thanks :) and buro9, you rock those fixes were cool ;)
Justice
11-01-2004, 07:59 AM
Does this hack still work for posters with search disabled? I want only certain users to be able to use the search (to save CPU), but I'd like for everyone to use this ideally.
docvader
11-24-2004, 05:38 PM
Chrisvonc, how did you add the text next to the box again? It's a great idea, but I'm not very good at writing this code stuff.
Thanks.
alkatraz
11-25-2004, 10:33 PM
I've just installed this on vb3.03, works great
zurih
01-09-2005, 01:32 PM
installed on 3.0.5, works perfect!
thanks!
AN-net
03-01-2005, 06:50 PM
installed on 3.0.7 and it works great. also modified mine so it only gets topics within the last 5 months(my forum policy is dont bump threads older than 5 months).
-=Sniper=-
03-02-2005, 11:11 PM
hi, sorry I just did a quick install, and I get this Invalid SQL:
SELECT threadid, MATCH(title) AGAINST ('ati probelm') AS score
FROM thread
WHERE MATCH(title) AGAINST ('ati probelm')
AND open <> 10
LIMIT 5
mysql error: Can't find FULLTEXT index matching the column list
mysql error number: 1191
do I need to enable full text search?
pauloo
12-23-2005, 09:01 AM
Exist for VB 3.5?
Thank you
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.