Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2005-07-01 01:30:44

dmeehan
New Member
Registered: 2005-06-24
Posts: 9

Re: search only one section?

awesome. thanks!

Offline

#17 2005-07-11 15:12:54

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

Got it working (no problem) as per Zem and Mary’s instructions.

I’d like to take this to the next step by replacing the
<code>
<txp:search_input section=“mysection” />
</code>
with my own txp form called search_news.

I’ll use the following in my page template
<code>
<txp:output_form form=“search_news” />
</code>

And my TxP form (saved as Misc) will look like this…
<code>
<div id=“searchbox”>
<form action=”/” method=“get”>
<input type=“hidden” name=“s” value=“search” />
<p><label for=“searchbox”>Search Recent News Articles</label></p>
<input type=“text” name=“q” class=“searchfield” size=“10” />
<input type=“submit” class=“button” value=“Find” />
</form>
</div>
</code>

My question is, where should the [section=“mysection”] go? In my txp form to call my seacrh form or in the search form itself?

Last edited by Ray (2005-07-11 15:25:46)

Offline

#18 2005-07-11 17:03:04

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: search only one section?

This is great. Also is it possible to search links or images? It seems that you can only search articles currently.

Offline

#19 2005-07-12 00:33:01

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

Re: search only one section?

Jeff: I don’t believe so (yet, anyway).

Ray: You’d point your form to the section url in question (action="/section-name"), that’s what that section parameter does.

Offline

#20 2005-07-12 00:35:17

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

I’m just in the process of typing out how I got it to work. BRB

Offline

#21 2005-07-12 00:53:34

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

I thought I had it working but no.

Yes, I understand the section parameter (that was a quick copy and paste… my bad).

OK, here are the tags and forms I using.

Call the search form on the news page
<code><txp:output_form form=“search_input” section=“news” /></code>

The news page article tag
<code><txp:article limit=“5” searchall=0 /></code>

The search_input form
<code>
<form action=”/news” method=“get”>
<input type=“hidden” name=“s” value=“search” />
<label for=“searchbox”>Search News Archives</label>
<input type=“text” name=“q” class=“searchfield” size=“10” />
<input type=“submit” class=“button” value=“Find” />
</form>
</code>

But it AIN’t werkin’! WHAT am i doing wrong here. I want to search the news section only and have the search results show up on a custom page.

Offline

#22 2005-07-12 01:12:47

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

Re: search only one section?

You might try

form call
<txp:output_form form="search_input" />

form
<code><form action=”/search” method=“get”>
<label for=“searchbox”>Search News Archives</label>
<input type=“text” name=“q” class=“searchfield” size=“10” />
<input type=“submit” class=“button” value=“Find” />
</form></code>

search page
<code><?php $s = ‘news’; ?>
<txp:article limit=“5” searchall=0 /></code>

Offline

#23 2005-07-12 01:25:29

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

I’m outta ideas here. I can not get both a section only search AND custom search results page cooperating.

Mary, Thanks for your input…. but I’m at a stand still here. Can’t figure it out.

Offline

#24 2005-07-12 01:55:12

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: search only one section?

But it AIN’t werkin’!

Care to elaborate?


Alex

Offline

#25 2005-07-12 02:18:58

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

Searching one section only as per your instructions works fine. What I’m trying to accomplish is a one section only search that has it’s own search results page.

At first I thought it would be as simple as using a <span style=“color:#cc0000;”>search_input</span> form with a <span style=“color:#cc0000;”>section=“news”</span> in the tag. Like so.
<code><txp:output_form form=“search_input” section=“news” /></code>

Then my search_input form would have the following
<code>
<div id=“searchbox”>
<form action=”/search” method=“get”>
<label for=“searchbox”>Search News Archives</label>
<input type=“text” name=“q” class=“searchfield” size=“15” />
<input type=“submit” class=“button” value=“Find” />
</form>
</div>
</code>

But that didn’t do the trick. Instead of bringing up the search results for the news section only <b>it grabs results from the entire site.</b> The only way I can get a one section only search working is without a custom search results page and just using the tags you suggested. As soon as I build my own search_input form it shows results from the whole site.

Last edited by Ray (2005-07-12 02:19:53)

Offline

#26 2005-07-12 03:07:10

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

Maybe there’s another way to take care of the things I’m trying to accomplish with a custom search page.

Your solution as mentioned at the top of this thread works fine… however there are two primary issues I’d like to find a solution for.

1) My news page has an article limit of five. If I use the method you suggested then my search results (on that page) are also limited to five hits. If there are more than 5 hits then the Previous/Next page links simply go to the Previous/Next page of the NEWS section. NOT the search results. So, if I search my NEWS section for apples then I will get a list of five hits for apples from my NEWS section but the Previous/Next links don’t go to the next five hits… it goes to the Previous/Next Page of the news section…. pg2 of NEWS.

2) If I can’t have a custom search page AND search by section only then a custom label for the search form would do. There are three primary sections on the site that have articles. NEWS section, PRODUCTS section and EVENTS section. Being able to search each section only would be a bonus. Being able to have a custom search label for each search function would be double bonus.

Being able to have a search by section only AND have a custom search results page for each section PLUS have custom labels for each search form would be simply dreamy. Ice cream and kittens and warm fuzzy mittens kinda dreamy.

Last edited by Ray (2005-07-12 03:13:40)

Offline

#27 2005-07-12 23:39:46

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: search only one section?

This might help, on your news page template:

<pre><code>
<txp:if_search>
<h3>Search results:</h3>
<txp:article searchall=0 limit=50 />
<txp:else />
<txp:article limit=5 />
</txp:if_search>
</code></pre>


Alex

Offline

#28 2005-07-13 01:57:09

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

I love you. That worked like a charm and will do just fine.

Offline

#29 2005-07-13 03:29:01

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

Zem… I’m sure I know the answer to this but I want to check anyway. Can I safely remove the wraptag from the search function in publish/taghandlers.php. Line 483. I’d rather control the form and it’s wrap tag with another method.
<code> function search_input($atts) // input form for search queries { global $q, $permlink_mode; extract(lAtts(array( ‘form’ => ‘search_input’,
/* ‘wraptag’ => ‘p’,
*/ ‘size’ => ‘15’, ‘label’ => ‘Search Archives’, ‘button’ => ‘’, ‘section’ => ‘’, ),$atts));
</code>

Offline

#30 2005-07-13 04:27:27

Ray
Member
Registered: 2004-03-02
Posts: 159

Re: search only one section?

Also… is it possible to include a search of multiple sections at once?… but not all sections. If so, how do I include those section in the txp tag

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

Offline

Board footer

Powered by FluxBB