Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » LiveSearch

#1 2004-07-21 16:35:12

octover
Archived Plugin Author
From: Sandy, UT
Registered: 2004-04-08
Posts: 3
Website

LiveSearch

I just wanted to let you all know about a very cool thing called LiveSearch that is going around. To get it to work will take some knowledge and skill to troubleshoot it. I wish I had time, but I am swamped right now, just thought I would throw it out to the community and then as time allows or if others can lend a hand to helping others get this work. It only (can possibly work for now) works in Mozilla/IE/Safari 1.2. I found it off of xlab about LiveSearch being added to the site. That lead me to where he got it from over at Bitflux. Reading the comments when I was looking for more of a drop in set of code for textpattern led me to creatimation.net I just downloaded the zip file he provides, uploaded them and changed the live-search.php to actually query the database. Taking the necessary bits from his search page and putting them into my Textpattern page template. You can see it in action at pretty much any site above or on my website.

Here is the code I used in live-search.php, basically borrowing Dean’s query for searching textpattern, but simplified. I bet there is a better way to package this all up into an easy to drop in package for textpattern.

[edit to change the code to better display a message if there is no results]

<code>
<?php
header(“Content-type: text/xml;charset=utf-8”);

include ‘textpattern/config.php’;

mysql_connect ($txpcfg[‘host’], $txpcfg[‘user’], $txpcfg[‘pass’]);
mysql_select_db ($txpcfg[‘db’]);

$q = $_REQUEST[‘s’];
$searchQ = mysql_query (“select ID, Title, Body_html, Section, unix_timestamp(Posted) as uPosted, match (Title,Body) against (‘$q’) as score FROM textpattern WHERE Title rlike ‘$q’ or Body rlike ‘$q’ and Status = 4 and Posted <=now() order by score desc limit 40”);
?>
<p><?php if (! mysql_num_rows ($searchQ)) { echo “<strong>No</strong> “; } ?>Results for: <strong><?=$_REQUEST[“s”]?></strong></p>
<ul> <?php if (mysql_num_rows ($searchQ)) { while ($searchR = mysql_fetch_object ($searchQ)) { echo “<li><a href=’/article/”.$searchR->ID.”’>”.$searchR->Title.”</a></li>\n”; } } ?>
</ul>
</code>

Last edited by octover (2004-07-21 16:46:33)

Offline

#2 2004-11-10 18:02:45

danielk
Member
Registered: 2004-03-04
Posts: 24

Re: LiveSearch

I’m very interested in making this work, but am not great at PHP. I’m using TXP1.0rc1 with a database using table prefixes within TXP, and currently am not getting any results for the searches. I’m thinking it’s related to the prefix. I’m not seeing anything that reference the PFX code, and I can’t figure out where to place it.

Also, would it be possible to tie this to use the internal search function and output the xml via the customized search_results form, or similar?

Last edited by danielk (2004-11-10 18:03:20)

Offline

#3 2004-12-23 16:56:57

tkn
Member
From: New York
Registered: 2004-06-29
Posts: 39
Website

Re: LiveSearch

Sorry to resurrect an old thread, but I have also been trying to get this script to work without much luck. I always get a No Results return, and I have a feeling it is basically the MySQL query, but I am not so strong with those as to know what is wrong with it. The only thing I noticed from the script above is that it seems to be asking for Body_html, but then using Body throughout the rest (Although that is given my extremely poor knowledge of MySQL). Anyone have any thoughts on this?

Offline

#4 2005-05-05 09:28:30

nils73
Member
From: Germany (Duesseldorf)
Registered: 2004-07-07
Posts: 15
Website

Re: LiveSearch

I have been searching this forum for plugin-solutions featuring Ajax, especially a search-feature. In addition I googled a few seconds and found a German website about TXP and livesearch by Bitflux. Hey — it works! There are a few other Plugins that might come in handy.

Offline

#5 2005-05-05 14:51:18

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: LiveSearch

Nice find nils! definitely something to play with here.

Offline

#6 2005-05-05 16:24:05

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: LiveSearch

Don’t read German very well.

I assume you save this file to textpattern/publish/livesearch.php

Then hack the publish.php file to add the following:<pre><code>
if( gps(‘ls’) ) { include txpath.’/publish/livesearch.php’; exit(livesearch( gps(‘ls’),20 ));
}</code></pre>

Am I right or am I right?

Last edited by mrdale (2005-05-05 16:25:50)

Offline

#7 2005-05-05 16:58:03

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

Re: LiveSearch

That seems to be correct mrdale.

I’m throwing this all together as a plugin. Anyone interested in testing it out? Email me if you are.

EDIT: Thanks for the offers and the help. Go get rss_live_search.

Last edited by wilshire (2005-05-06 04:25:13)

Offline

#8 2005-05-05 23:49:21

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: LiveSearch

::emailing wilshire::


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#9 2005-05-06 01:39:17

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: LiveSearch

Same here!

Offline

#10 2005-05-06 04:02:43

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: LiveSearch

rss_livesearch works beautifully :)


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#11 2005-05-08 15:37:09

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: LiveSearch

yes,that does work well, I wish I had the knolledge to modify this to produce some more filtered reasonable output.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#12 2005-06-18 19:34:03

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: LiveSearch

Trying to forward the searchresults to a diferent section/template named searchresults gives me the following errors :
<code>
Warning: extract() [function.extract]: First argument should be an array in G:\sites\cybermarios7\textpattern\publish\taghandlers.php on line 1015

Warning: extract() [function.extract]: First argument should be an array in G:\sites\cybermarios7\textpattern\publish\taghandlers.php on line 822

Warning: extract() [function.extract]: First argument should be an array in G:\sites\cybermarios7\textpattern\publish\taghandlers.php on line 1015

Warning: extract() [function.extract]: First argument should be an array in G:\sites\cybermarios7\textpattern\publish\taghandlers.php on line 1015
</code>

I unsed the searchto attribute eg.: searchto=“searchresults”

what could be wrong ?

regards, marios

Last edited by marios (2005-06-18 19:34:29)


⌃ ⇧ < ⌃ ⇧ >

Offline

  1. Index
  2. » Archives
  3. » LiveSearch

Board footer

Powered by FluxBB