Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-02-25 11:09:40

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

make future articles appear in searches

I’ve seen some folks mention it involved a bit of hacking… any top tips?

Offline

#2 2006-02-25 11:33:52

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: make future articles appear in searches

no expert, so at your own risk etc… but you want to remove this sort of phrase: and Posted <=now()

look for that in publish/search.php

and someone might chime in to confirm or expand on this (hopefully : )

Offline

#3 2006-02-25 12:30:15

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: make future articles appear in searches

Yep, that’s about it. :)

(‘course I have to disclaim that by saying that wouldn’t be officially supported.) :)

Offline

#4 2006-02-25 15:49:07

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: make future articles appear in searches

disclaimers accepted :)

in my publish/search.php starting line 34 I had this:
<code>and Status = 4 and Posted <=now() order by score desc limit 40”);</code>

which I changed to this
<code>and Status = 4 order by score desc limit 40”);</code>

but still, my future articles aren’t appearing in my search results…
did I do it right?

Offline

#5 2006-02-25 19:59:29

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,643
GitHub Twitter

Re: make future articles appear in searches

…could you try this :

<strong>Line 34 :</strong> <code> and Status = 4 and (Posted <=now() and Posted >now()) order by score desc limit 40”);</code>

I’ve try and it seems to work. But I’m not sure if this is a well formated PHP instruction.

Last edited by Pat64 (2006-02-25 20:00:14)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#6 2006-02-26 04:46:31

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: make future articles appear in searches

$rs = safe_rows("*, ID as thisid, unix_timestamp(Posted) as posted, Title as title,
	match (Title,Body) against ('$q') as score",
	"textpattern",
	"(Title rlike '$q' or Body rlike '$q') $s_filter
	and Status = 4 order by score desc limit 40");

Should work just fine. What you’ve got actually shouldn’t as in english that’d be: “and Posted is earlier than now or is now, and Posted is later than now” (and a date can’t be both earlier/now AND later at the same time).

Offline

#7 2006-02-26 09:52:59

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,643
GitHub Twitter

Re: make future articles appear in searches

…Great explanation Mary. Thank you! :-) Your are the best pieman and Mary. Thanks.

It works, very fine. And I’ve got what I want : a separate display betwen past and futures articles in the searchs.

How I’have made that. Easy, follow this :

Part 1.

I use only one thing. This great plugin <a href=“http://textpattern.org/plugins/530/chhifdata” Title=“Get this amizing plugin”><strong>chh_if_data</strong></a> (installed and actived, of course :-)

I’ve create a section named “search” (or anything else, if you want) with a template which contains this following code :

<code>
<txp:article time=“future” searchall=“1” />
<txp:search_result_count />
<txp:chh_if_data>
<h2>Other results :</h2>
<span>(before the date of
<txp:php>
$today = date(“m j Y”);
echo $today;
</txp:php> )</span>
<txp:article searchall=“1” />
</txp:chh_if_data>
</code>
<br />
<code>
<txp:if_search>
<txp:search_result_count />
<txp:php>
global $thispage; global $q;
echo( ($thispage[‘total’]==0 ?
“<p id=\“msgresult\”>Sorry, no result for your search.</p>” :
“<p id=\“msgresult\”>Here is the result of your search for \”<strong>$q</strong>\” :</p>” ) );
</txp:php>
</txp:if_search>

</code>

So, I’have got what I want : this separate display between future articles (<code><txp:article time=“future” searchall=“1” /><code>) and past ones (<code><txp:article searchall=“1” /></code>).

In your default style sheet you have to place this positionning css :

<code>
#msgresult {
position: absolute;
top: 160px;
}
</code>

cause without that, the search result message in <code><p id=“msgresult”></code> will be display <em>after</em> the TXP result search.

Part 2.

I’ve changed <em>all</em> my search input tags in my templates like this :

<code><txp:search_input section=“search” />
</code>

and of course, I’ve change the line 34 in the search.php file like pieman suggested before :

<em>Line 34.</em><code> and Status = 4 order by score desc limit 40”);
</code>

That’s all. I think, it must to be arrange a little bit. But today I’ve any time. Sorry.

Last edited by Pat64 (2006-02-26 18:24:51)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#8 2006-02-26 15:28:12

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: make future articles appear in searches

@mary/nardo

Your suggestion makes sense, and I’ve changed publish/search.php exactly as you said,
<code>$rs = safe_rows(“*, ID as thisid, unix_timestamp(Posted) as posted, Title as title, match (Title,Body) against (‘$q’) as score”, “textpattern”, “(Title rlike ‘$q’ or Body rlike ‘$q’) $s_filter and Status = 4 order by score desc limit 40”);</code>

but my future article still wont appear in the search results.

If you have a moment, the article I want to show is this one: http://www.bristolmusicfoundation.com/events/south-west-sound-2006

I dunno if it’s significant, but I tried removing the above section of code completely from search.php and the search form still functioned as before. weird.

Offline

#9 2006-02-26 15:29:55

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: make future articles appear in searches

@ Pat64

I think you might have forgotten to close your code tags somewhere up above!
its all gone monospaced ;)

Offline

#10 2006-02-26 16:46:14

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,643
GitHub Twitter

Re: make future articles appear in searches

@ pieman :

Here is my file I use for my template named search in <strong>txt format</strong> or in <strong>rtf format</strong> (links deleted)

Try it, and tell me if it’s OK. It works on my local installation of TXP 4.0.3 (r1188).

P.S. (in french, sorry) Il me reste à concaténer le message pour inclure les résultats dans la phrase elle même. (Now in English : voilà :-)

Last edited by Pat64 (2007-11-15 08:04:28)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#11 2006-02-26 16:51:19

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: make future articles appear in searches

oh sorry, I meant actually in this forum page!

everything in this page below where you say “So, I’have got what I want : this separate display between future articles” is in a monospaced font, as if it were all between code tags, so I think you might have forgotton to close one up there.

thanks for the offer though, very nice of you :o)

Offline

Board footer

Powered by FluxBB