Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-28 22:11:00

cpk
Member
Registered: 2005-08-07
Posts: 62

How do I style search page results

I have searched the forum and the wiki high an low to accomplish what I thought would be a simple customization but can find no solution that works. What I want to do is style the search results to appear in a definition list as I believe that this would be more semantically appropriate for the content.

Since you cannot apply the wraptag and break attributes to either the <txp:article /> or <txp:output_form /> tags, I am at a loss as to how I would be able to style my search result listing in either an unordered list or definition list. Has anyone else done something similar?

I am using TxP 4.0.3 and have a separate search page defined.

Thanks,

cpk

Offline

#2 2006-09-28 22:41:02

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

Re: How do I style search page results

Search results use the article form ‘search_results’. You can style that in whatever way you want.

Offline

#3 2006-09-29 00:32:16

cpk
Member
Registered: 2005-08-07
Posts: 62

Re: How do I style search page results

Thanks Els,

That’s what I thought but I guess I was going about it all wrong. I thought I could apply an html tag directly to the <txp:article /> tag or a <txp:output_form form="search_result" /> tag by calling the wraptag and break attributes but that did not work (the wiki confirmed these tags don’t take attributes)

I have since come up with one solution by applying the individual <dt> and <dd> tags to the search_results form and wrapped the <txp:article /> tag in the page template with the <dl> tag.

So far, so good.

I do have one question though, is the “state” of a search results page an article_list or is it an individual_article? It seems as if it behaves more like an individual_article. I suspect that this is the case since I get no results when I use an article_list conditional statement on the search page template. I suppose my only alternative is to use the chh_if_data plugin to provide a “no results found” message.

cpk

Offline

#4 2006-09-29 01:19:03

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

Re: How do I style search page results

I do have one question though, is the “state” of a search results page an article_list or is it an individual_article? It seems as if it behaves more like an individual_article. I suspect that this is the case since I get no results when I use an article_list conditional statement on the search page template.

No, it’s definitely an article list (regardless of the number of results). Can you clarify on what you mean by that last sentence?

Offline

#5 2006-09-29 10:48:19

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

Re: How do I style search page results

cpk wrote:

I suspect that this is the case since I get no results when I use an article_list conditional statement on the search page template.

If you were thinking of using something like
<code>
<txp:if_article_list>
code for search results here
<txp:else />
code for no results found
</txp:if_article_list>
</code>
then that won’t work, no. chh_if_data is a better way to go.

Offline

#6 2006-09-29 15:26:56

cpk
Member
Registered: 2005-08-07
Posts: 62

Re: How do I style search page results

Mary wrote:

Can you clarify on what you mean by that last sentence?

What I meant was that I wanted to provide a more detailed message when a search returned no results instead of just the general “0 articles found”.

Els,

Yes, I was attempting something along the lines of your code example but found that it did not work.

In addition to giving a detailed message with a 0 result search, I wanted to provide a more detailed search result when there is only one result and a more standard result when 2 or more results were found in a search. That was why I asked if the search_result was either a individual_article or article_list.

Thanks,

cpk

Offline

#7 2006-09-29 20:51:15

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

Re: How do I style search page results

There may be another way, though limited. The tag <txp:search_result_count /> will output one of

  • 0 articles found
  • 1 article found
  • 2 – ~ articles found

The text ‘article found’ and ‘articles found’ is in the txp_lang table. You could use chh_if_data for when there are no search results, and modify the text for 1 article found in the table. Something like
1 article found (that’s better than nothing)

Offline

Board footer

Powered by FluxBB