Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-07 19:29:27

rosastef
New Member
Registered: 2009-12-07
Posts: 2

Input search for one section without listing articles on same page

I am trying to figure out a way to have users search a specific section without listing the articles on the same page as the search form. (The documentation states that <txp: article> tag must be used for search to work.)

The page in question is here: http://lsl.is/frodleikur

You can see the search box at the top, then articles from 3 different categories in the 3 boxes below (using <txp:article_custom> tag). I want to get rid of the article list that appears below the boxes, but if I remove it the search function doesn’t work.

There must be a way around this somehow? Any suggestions? I’ve been stuck with this for hours :)

Offline

#2 2009-12-07 21:32:45

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Input search for one section without listing articles on same page

You would need to post your code for us to help you – but it would seem you need to use some search tags in your default page template.

I just created a search category on TXP Tips to help you find the info you need – I would start here.

Let us know if you need any more help!

Offline

#3 2009-12-08 11:18:55

rosastef
New Member
Registered: 2009-12-07
Posts: 2

Re: Input search for one section without listing articles on same page

Hi jstubbs and thx for your reply. I read what you suggested, good info but I already have search like that set up.

Here is the chunk of code from my site:

<div id="content"><br />

<div class="row" id="frodleikur-leit">
<h2>Leit að grein eftir efnisorði</h2>
<form method="get" action="http://lsl.is/frodleikur">
<p><input type="text" name="q" size="20" section="search" />
<input type="submit" value="Leit" class="submit"></p>
   </form><br />
</div>

<div class="row">
  <div class="column grid_4"><h2>Íslenskar rannsóknir</h2>
<txp:article_custom category="isl-rannsoknir" limit="4" form="title_only"/>
<h3><txp:category name="isl-rannsoknir">Sjá allar</txp:category></h3>  </div>

  <div class="column grid_4"><h2>Fyrirlestrar af námskeiðum</h2>
<txp:article_custom category="fyrirlestrar" limit="4" form="title_only"/>
<h3><txp:category name="fyrirlestrar">Sjá allt</txp:category></h3>  </div>

  <div class="column grid_4"><h2>Aðrar greinar</h2>
<txp:article_custom category="adrar-greinar" limit="4" form="title_only"/>
<h3><txp:category name="adrar-greinar">Sjá allar</txp:category></h3></div>
</div>

 <h2>Fróðleikur og greinar</h2>
 <txp:article searchall="0" form="static" listform="articles_in_frodleikur"  limit="300"/>


<!-- footer -->
	<div id="foot"><form method="get" action="/search">
	<p><input type="text" name="q" size="15"/>
<input type="submit" value="Leit" class="submit"></p>
		</form>
<txp:output_form form="footer" /></div>

</div>

I have a section called search on my site where all general site search results are displayed. (e.g. I have a search box in the footer of all my pages). That works fine.

However, for section frodleikur I wanted users to be able to search all the articles in that specific section (there are quite a lot of articles in that section and this is the most logical way for people to find sth of interest). The search works and only displays results from this single section, but only if I leave in the <txp:article searchall=“0” form=“static” listform=“articles_in_frodleikur” limit=“300”/> part, but that is something I don’t want to have visible when the page is rendered.

I am looking for a way around that. Plz help.

Last edited by rosastef (2009-12-08 11:20:09)

Offline

#4 2009-12-08 14:02:35

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Input search for one section without listing articles on same page

I think you are missing a couple of things:

The form for your section articles:

<form method=“get” action=“http://lsl.is/frodleikur”>
<p><input type=“text” name=“q” size=“20” />
<input type=“submit” value=“Leit” class=“submit”></p> </form>

The section attribute has been removed.

For the search results:

<txp:if_search>
<txp:article limit="10" pgonly="1" />
<txp:if_search_results>
<h2><txp:search_result_count text="" /> results for "<txp:search_term />":</h2>
<txp:else />
<h2>Sorry, no results for "<txp:search_term />".</h2>
</txp:if_search_results>
<txp:article searchform="search_results" limit="100" sort="Posted desc" />
</txp:if_search>

For search results, txp:article uses searchform="search_results" by default. Its not necessary to set this attribute but helps jog the memory, which is why I use it. Then I adjust the search_results form.

In that form use <txp:search_result_excerpt />.

Offline

Board footer

Powered by FluxBB