Tags:
create new tag
, view all tags

Question

How to have a query text field, and have the result processed in a module. I only want to enter a keyword, and in my own module a lookup is done in SQLite. The result is displayed in TWiki. Thus basically a search in an own DB. It seems to me a function ought to exist, but can't locate it.

Environment

TWiki version: TWikiRelease04Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Linux
Web server: thttpd
Perl version: 5.8
Client OS:  
Web Browser: Firefox
Categories: Documentation

-- TonTLam - 26 Apr 2006

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

You might want to investigate DatabasePlugin

-- CrawfordCurrie - 26 Apr 2006

Or the more extensive DBIQueryPlugin. See also Tag:database.

-- PeterThoeny - 27 Apr 2006

Thanks for the pointers. On its own it is very easy to read a SQLite DB from TWiki.

use DBI;

$db = "<path>/phonelist";
$dbh = DBI->connect("dbi:SQLite:dbname=$db")
        or die "couldn't connect to database: " . DBI->errstr;
$query = "select * from phone";
and so on ...

I should rephrase my question:
How to have a text field query, to specify a search condition in. From there press [GO], and the search is done, and displayed. Thus like in the WebSearch.

I assume it will be something liek this in my own TWiki module

 $_[0] =~ s/%PHONE%/&TextQueryPhone("tag")/e;

This causes an text query input field. Via the tag I read the value. And that is passed to some SQL statement. How to get this back in the module ? Likewise the %COMMENT%. I did check the code, but wasn't able to discover what really is going on.

-- TonTLam - 27 Apr 2006

You can pass URL parameters into your custom variable, such as: %PHONE{ name="%URLPARAM{name}" }%. Basically like the WebSearch topic.

In the Plugin, you can parse the value and pass that along to your subroutine. Read existing Plugin code to see how to parse the parameters. See example in TagMePlugin code with TWiki::Func::extractNameValuePair().

-- PeterThoeny - 27 Apr 2006

 
Topic revision: r5 - 2006-04-27 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.