Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
section limited search
I’ve tried following these instructions but as far as I can see my txp code is different, which has got me very confused.
Instructions say:
First, you need to point the search input to the current section page, by adding to the <txp:search_input /> the attribute section with the current section name as the value. Then, in order to display the search results only for that section, you have to add searchall=”0” as attribute for the <code><txp:article /></code> tag on that page.
Here’s the search page I’m using:
<code><txp:output_form form=“header” />
<txp:article />
<txp:output_form form=“footer” /></code>
And here’s the search input form I’m using:
<code><form action=”/index.php” method=“get”> <input type=“hidden” name=“s” value=“search” />
<input type=“text” name=“q” value=”“ size=“15” /> <input type=“submit” value=“search” /> </form></code>Can anyone see what gives, how I limit the search to the section called “words”?
Offline
#2 2006-04-08 15:42:10
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
Edit: sorry, didn’t read your question properly, so I deleted my first answer.
Right answer (I think): replace the search input form’s content with <txp:search_input section="words" />
. And replace <txp:article />
with <txp:article searchall="0" />
.
That should do it.
Last edited by els (2006-04-08 15:49:21)
Offline
Re: section limited search
OK…but where does the <code><txp:search_input section=“words” /></code> go?
As far as I can see, its not a case of inserting a few words into existing code. Its got to go in here somewhere: <code><form action=”/index.php” method=“get”> <input type=“hidden” name=“s” value=“search” /> <input type=“text” name=“q” value=”“ size=“15” /> <input type=“submit” value=“search” />
</form></code>
Offline
#4 2006-04-08 20:06:56
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
No, you can forget about that last piece of code. Put <txp:search_input section="words" />
on your page (that is the page that your section ‘words’ is using) wherever you want to display it. See also here for additional attributes.
Last edited by els (2006-04-08 20:08:26)
Offline
Re: section limited search
OK, I was changing the search page, not the words page. Not sure if the instructions were unclear…it’s also possible I was just getting confused.
Inserting <code> <txp:search_input section=“words” /> </code> seems OK, but does not in itself restrict the search to ‘words’.
Inserting <code><txp:article searchall=“0” /> </code> breaks it – it generates an empty page, with no results….
Last edited by jameslomax (2006-04-08 22:12:23)
Offline
#6 2006-04-09 00:20:06
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
Try this:
<code>
<txp:if_search>
<txp:article searchall=0 />
<txp:else />
<txp:article />
</txp:if_search>
</code>
But if this doesn’t help, I’m out of ideas… :(
Offline
Re: section limited search
Where should I put that code? Getting pretty confused here…..
Offline
#8 2006-04-09 13:26:47
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
On your ‘words’ page, where you want the articles and search results to be displayed.
Last edited by els (2006-04-09 13:27:36)
Offline
Re: section limited search
That breaks the page – it generates a series of extracts in the right column, that shouldn’t be there. Maybe because I followed these instructions – I don’t know.
Offline
#10 2006-04-09 19:30:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
Ah, you want to have a separate page/section for displaying search results, and search only in one section. To my knowledge that’s not possible (someone correct me if I’m wrong). If you want to search in one section, the search results have to be displayed on that same section page. So you should insert the code I mentioned in your ‘words’ page template.
So <txp:search_input section="words" />
goes where you want the search input field to show (right column?), and
<code>
<txp:if_search>
<txp:article searchall=0 />
<txp:else />
<txp:article />
</txp:if_search>
</code>
goes where your articles and search results should be displayed (which is not in your right column I assume).
Offline
Re: section limited search
OK thanks. I’ll have to retrace what I did, delete it, and start again taking your advice and see if it works. Which is not easy (or fun) when I only have a tenuous grasp of what I’m doing :(
Last edited by jameslomax (2006-04-12 09:52:12)
Offline
#12 2006-04-12 14:10:09
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: section limited search
Just give it some time ;) Textpattern isn’t easy. Don’t use it yet for things that have to be done, just play around with it for a while. You’ll get the hang of it.
Offline
Pages: 1