Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-01 01:24:21

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

rah_file_search

Search files kinda like articles.

More info and downloads

Offline

#2 2009-03-20 17:37:20

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

Re: rah_file_search

Is there a way to change this to search for links?

Offline

#3 2009-03-25 05:19:01

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_file_search

dl33 wrote:

Is there a way to change this to search for links?

Yep. Kinda. Or Done. You deside. Ahem.

Sooo…. rah_link_search or smthg ;)

Offline

#4 2011-02-01 16:28:22

Addison
Member
From: Flowood, Mississippi
Registered: 2004-08-30
Posts: 34
Website

Re: rah_file_search

Before I go tinkering, I was curious if there’s a way to use <txp:if_search> and <txp:if_search_results> with this plugin? All I’m looking for at this point is a way to display a custom message if there are no results.

Thanks!

Offline

#5 2011-02-20 19:51:50

ax
Plugin Author
From: Germany
Registered: 2009-08-19
Posts: 165

Re: rah_file_search

I have tried all your examples with rah_file_search and rah_link_search, like

<txp:search_input />
<txp:rah_file_search />

but search results always return articles, not files or links, using TxP 4.3 and 4.2. What am I missing?

Offline

#6 2011-02-21 02:19:40

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_file_search

ax wrote:

but search results always return articles, not files or links, using TxP 4.3 and 4.2. What am I missing?

The tag doesn’t return article results. Can you post a tag trace from the problem page in question?

Offline

#7 2011-02-21 20:13:48

ax
Plugin Author
From: Germany
Registered: 2009-08-19
Posts: 165

Re: rah_file_search

Gocom wrote:

The tag doesn’t return article results. Can you post a tag trace from the problem page in question?

I have stripped down the query page. The tag trace looks like this and still returns articles:


<!-- txp tag trace: 
[SQL (0.007429838180542): select name, data from txp_lang where lang='en-gb' AND ( event='public' OR event='common')]
[SQL (0.043230056762695): select name, code, version from txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (0.010585069656372): select title from txp_section where name='test']
[SQL (0.0039339065551758): select name from txp_section where `name` like 'test' limit 1]
[SQL (0.00057005882263184): select page, css from txp_section where name = 'test' limit 1]
[SQL (0.00042581558227539): select host from txp_log where ip='***' limit 1]
[SQL (0.00040006637573242): insert into txp_log set `time`=now(),page='/test',ip='***',host='***',refer='',status='200',method='GET']
[SQL (0.00062298774719238): select user_html from txp_page where name='test']
[Page: test]
<txp:section title="1" />
	[SQL (0.00050091743469238): select title from txp_section where name='test']
<txp:css n="textile" />
<txp:article form="waw_archive" />
	[SQL (0.00077986717224121): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('test')]
	[SQL (0.001255989074707): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('test') order by Posted desc limit 0, 10]
	[article 522]
	[SQL (0.0004889965057373): select Form from txp_form where name='waw_archive']
	[Form: waw_archive]
	<txp:title />
	<txp:excerpt />
	<txp:body />
		<txp:search_input />
			[SQL (0.0007021427154541): select form from txp_form where `name` = 'search_input' limit 1]
		<txp:rah_file_search />
[ ~~~ secondpass ~~~ ]
 -->

Offline

#8 2011-02-22 05:15:18

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_file_search

ax wrote:

I have stripped down the query page. The tag trace looks like this and still returns articles:

The tag trace you posted isn’t from a search page. The tag will only return something when there is active search (?q URL parameter is set).

Also, the tag seems to be placed inside an article. You probably don’t want that, because now the tag is called on every article, outputting repeated results. It should be placed to the page template (or to a form that is then called on the page template).

Offline

#9 2011-02-22 05:32:19

ax
Plugin Author
From: Germany
Registered: 2009-08-19
Posts: 165

Re: rah_file_search

I don’t get it. This page template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<txp:css n="test" />" type="text/css" media="screen" />
</head>

<body id="default">

<txp:search_input />
<txp:rah_file_search />

<txp:article form="waw_archive" />

</body>
</html> 


results in a /?q page when searched, but it contains articles, not files.

Offline

#10 2011-02-22 05:43:22

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_file_search

ax wrote:

results in a /?q page when searched, but it contains articles, not files.

Please, post the full tag trace from that page. Anyway, it indeed will return articles (too) as you have an article tag on the page template. If you are wondering if the plugin even works, yes it works perfectly fine.

What you should see in your tag trace when the plugin is used correctly is similar to this:

<txp:rah_file_search />
	[SQL (0.000214099884033): select id from txp_file where (filename rlike '2' or description rlike '2') and status = '4']
	[SQL (0.000206232070923): select * from txp_file where id = 1]
	[SQL (0.0001220703125): select Form from txp_form where name='files']

That’s when searched for “2” (?q=2).

Last edited by Gocom (2011-02-22 05:49:55)

Offline

#11 2011-02-22 08:07:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_file_search

Released version 0.2. Changelog:

  • Now only causes one extra query; uses file_download_list() instead file_download().
  • Now accepts all the same attributes as file_download_list tag.
  • Now suppresses “Page template doesn’t contain article tag.” notice when on search context.
  • Now uses uses same type of matching pattern as Textpattern.
  • From now on equires Textpattern version 4.2.0 or newer.

More info and downloads

Offline

#12 2011-02-22 09:07:42

ax
Plugin Author
From: Germany
Registered: 2009-08-19
Posts: 165

Re: rah_file_search

Ok, I now have a fresh textpattern installation and created this test page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<txp:css n="test" />" type="text/css" media="screen" />
</head>

<body id="default">

<txp:search_input />
<txp:rah_file_search />

</body>
</html> 

When I enter “Welcome” into the search box it returns the “Welcome to your site” article, but not the “Welcome” file that I uploaded. This file has “Welcome” in its filename, in its title, and in its description, but is not returned. The full tag trace of the search result is here and the output from the search page is here.

Offline

Board footer

Powered by FluxBB