Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-20 16:49:22

Bellezza
New Member
Registered: 2009-06-08
Posts: 5

Search page Issues

I have a question about the search function. Right now our search page code is in the home page code. Therefore, whenever someone searches for something, things that are specific to the home page, (i.e. a featured article section, images, etc) show up above the results. Is there a way I can make it so that this does not happen?

I’m not familiar enough with textpattern to understand how it all really works. I tried moving it to a different page, but still the front page images and stuff were showing up on the search results page.

I also tried an if else code for the page, but that just made it worse. Maybe I wrote the if else code incorrectly.

Any suggestions? I would greatly appreciate any help!

Thanks!

Offline

#2 2009-11-20 17:08:41

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Search page Issues

You can move the search to its own section, this article on thresholdstate.com shows how to do it. Post back here if you need help :)

Offline

#3 2009-11-20 18:05:03

Bellezza
New Member
Registered: 2009-06-08
Posts: 5

Re: Search page Issues

I’m afraid I don’t understand that well enough. I created a new section and a new page that was copied off the homepage. I deleted everything off the homepage. Set the section as directed, but where do I add this? <txp:search_input section=“search” />

I don’t have any other search inputs. The only thing I can find in the other pages related to search is this:
<li><a href=”#search”><txp:text item=“go_search” /></a></li>

And also a few bits about the Search Results:
<h2><txp:if_search>Search Results: <txp:if_section name=“press-room”> Press Releases</txp:if_section><txp:else /><txp:if_article_list><txp:if_section name=“press-room”>Press Room</txp:if_section></txp:if_article_list><txp:if_individual_article><txp:if_section name=“press-room”>Press Release</txp:if_section></txp:if_individual_article></txp:if_search><txp:if_section name=“press-room”><txp:if_category name=“releases”>: <txp:category title=“1” /></txp:if_category><txp:else /><txp:section title=“1” /></txp:if_section></h2>

Am I doing this wrong?

Sorry I’m helpless. Haha.

Offline

#4 2009-11-20 19:36:14

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Search page Issues

Bellezza wrote:

And also a few bits about the Search Results:

I’m not sure what this code is supposed to do, but if it’s not doing it it’s because of incorrect tag use ;) You must close the conditional tags after the ‘else’ part, not before it. Like this:

<txp:if_section name="press-room">
	Press Releases
<txp:else />
	<txp:if_article_list>
		<txp:if_section name="press-room">Press Room</txp:if_section>
	</txp:if_article_list>
	<txp:if_individual_article>
		<txp:if_section name="press-room">Press Release</txp:if_section>
	</txp:if_individual_article>
</txp:if_section>

and

<txp:if_category name="releases">
	: <txp:category title="1" />
<txp:else />
	<txp:section title="1" />
</txp:if_category>

where do I add this? <txp:search_input section="search" />

That will display the search box, so you should place it on every page (template) where you want it to appear.

Here’s an example code for your ‘search’ page. Start with a simple code like this to display the search results, if you’ve got it working we can refine it.

<h2>Search results for '<txp:page_url type="q" />'</h2>

<txp:article limit="20" pgonly="1" />
<p><txp:if_search_results>
	<txp:search_result_count />
<txp:else />
	Your search returned no articles.
</txp:if_search_results></p>

<txp:article limit="20" />

Last edited by els (2009-11-20 19:37:46)

Offline

#5 2010-04-10 04:37:43

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Search page Issues

Hello Els!
I’m following your instructions on the seperate Search page. I’ve gotten the page to come up as it should, but the results do not show content that is in my static Pages (which are many right now). For design reasons, I’m not using Articles just yet for my primary pages (e.g.: About Us, Services, etc.)

Here’s the tag I’m using on my Search Results Page:

<h2>Search results for ‘<txp:page_url type=“q” />’</h2>
<txp:article limit=“20” pgonly=“1” />
<p><txp:if_search_results>
<txp:search_result_title />
<txp:search_result_excerpt />
<txp:search_result_url />
<txp:search_result_date />
<txp:search_result_count />
<txp:else /> Your search returned no articles.
</txp:if_search_results></p>

Am I doing something wrong? Maybe missing some important tag?

Thanks for your info (and that web article!)


Living the Location-Independent Life: www.NuNomad.com

Offline

#6 2010-04-10 13:07:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Search page Issues

laptophobo wrote:

but the results do not show content that is in my static Pages (which are many right now). For design reasons, I’m not using Articles just yet for my primary pages (e.g.: About Us, Services, etc.)

The search function only searches articles. So if you want your static pages to be searchable you’ll have to use articles. Whatever your design reasons are, I’m sure you’ll be able to do exactly the same using articles. There is a FAQ, scroll down to How do I manage static pages?

Last edited by els (2010-04-10 13:07:59)

Offline

Board footer

Powered by FluxBB