Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-08-19 04:31:20
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Searching only one section of the site, but that section is hidden?
I am going to have a section on my site with about 300 articles included in that section. I want all those articles to be hidden so they don’t show up on any other page of the site. I want to set up a simple search, to only search that one section. Will this still be possible to search that one section with the articles hidden, or will they need to be live?
Last edited by deronsizemore (2006-08-19 04:31:40)
Offline
#2 2006-08-22 23:06:56
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Searching only one section of the site, but that section is hidden?
bump
Anyone?
Offline
Re: Searching only one section of the site, but that section is hidden?
There is a status attribute in the txp:article tag, so having them hidden should not stop you from being able to display (and search) them, although that is not typical use.
Are these articles totally hidden or should they appear just in one section of your website. In the latter case, you can configure that section (tab: sections) to exclude the articles from being shown on the front-page.
Offline
#4 2006-08-22 23:48:40
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Searching only one section of the site, but that section is hidden?
Well here is the deal with what I am trying to acheive. It’s not life or death if I can’t make them hidden and still searchable, but anyway, I’m designing a golf site, and I am going to have a “course guide” section that will allow the visitor to search for golf courses in their area to get price, location, phone, etc, etc. There are going to be around 300 courses that I’m dealing with. The way I’ve got it set up is that each course will be in it’s own individual article and will be located in a section called “courses”. I want to make the each article in the “courses” section hidden from visitors unless they go to the “course guide” section and were to search for a course, then I’d like the corresponding articles to show up based on their search. Really what it comes down to, is I didn’t want a visitor to be able to type in “http://www.mysite.com/courses” and then have 300 articles show up on that page which is why I just wanted them hidden unless searched. Not a huge deal if I can’t do this, I’ll just have to assume people wont surf to “/courses” and if they do, oh well.
Thanks
Last edited by deronsizemore (2006-08-22 23:49:37)
Offline
#5 2006-08-23 00:56:52
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Searching only one section of the site, but that section is hidden?
In your page for “courses”, do:
<txp:if_individual_article>
<txp:article />
<txp:else />
<!-- whatever you want to show when they aren't looking at a single article -->
</txp:if_individual_article>
Nice and simple.
Offline
#6 2006-08-23 01:08:33
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Searching only one section of the site, but that section is hidden?
Mary, thanks for the code. I’ve not got a chance to try it out yet, but as always I’m sure it works fine. :o)
In doing this, the articles under the “courses” section will NOT be hidden, correct? They will all be live, but not shown because of the txp:if_individual_article conditional?
Offline
#7 2006-08-24 00:01:37
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Searching only one section of the site, but that section is hidden?
That’s right. They should be visible in a search, but otherwise won’t appear as a list.
It just occured to me: if your search for these articles is going to be on this same page, you will need a little tweaking of the above code:
<txp:if_individual_article>
<!-- show your individual articles with whatever form, etc, desired -->
<txp:article />
<txp:else />
<txp:if_search>
<!-- show your search results with whatever form, etc, desired -->
<!-- use searchall="0" so that we only retrieve articles from this section -->
<txp:article searchall="0" />
<txp:else />
<!-- whatever you want to show when they aren't looking at a single article or search results list -->
</txp:if_search>
</txp:if_individual_article>
If your search isn’t going to be on the same page – the default search behaviour – then the first snippet should work fine.
Last edited by Mary (2006-08-24 03:49:15)
Offline
#8 2006-08-24 01:31:26
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Searching only one section of the site, but that section is hidden?
Well I’ll tell you what I’m planning and then maybe you can point me to the correct code of the two to use, because honestly (maybe I’m the only one?) but conditoinals confuse the crap out of me. The only one I’ve ever been able to get to work is a basic if_comments conditional for my “comment_invite” section of each article.
What I’m planning is this: I’m going to have a link in the navigation that says “Course Guide”. When the user surfs to the “course guide” section, they will see a basic search. This search will only search one section of the site (the courses section which contain the 300 or so articles for each course). Once search term is entered then on that same page the search results will show up.
Last edited by deronsizemore (2006-08-24 01:32:06)
Offline
#9 2006-08-24 03:48:00
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Searching only one section of the site, but that section is hidden?
Okay, that’d look something like:
<txp:if_individual_article>
<!-- individual course article -->
<txp:article form="default" />
<txp:else />
<txp:if_search>
<!-- course search results list -->
<!-- use searchall="0" so that we only retrieve articles from this section -->
<txp:article searchall="0" form="search_results" />
<p><txp:newer>Prev</txp:newer> · <txp:older>Next</txp:older></p>
<txp:else />
<!-- search form -->
<!-- make sure "section" is this section's name -->
<txp:search_input section="courses" />
</txp:if_search>
</txp:if_individual_article>
:)
Offline