Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Exluding articles from search results if custom field is something
I have a website where a custom field is used to specify if a company has seized to exist. So when a person is searching for companies, those articles that have a value in a specific custom field, should not show in the search results. Can this be done? The custom field is named Closed (Y) and if the field has a value Y then it shouldn’t show in the search.
Offline
Re: Exluding articles from search results if custom field is something
The simplest way is to hide things, wrapping the content of your search_results
form in if_custom_field
, but this breaks pagination:
<txp:if_custom_field name="Closed" value="Y">
<txp:else />
<!-- search results content -->
</txp:if_custom_field>
Using a “closed” section excluded from search results would be a cleaner solution.
Offline
Re: Exluding articles from search results if custom field is something
Alright, thanks for the code tip. :-) That works just fine, I think. In this case I won’t be changing sections for the closed business articles as that would change the URL structure.
Offline
Re: Exluding articles from search results if custom field is something
Then I would increase the value of limit
attribute in the “search” part of page form, to avoid half-empty search pages:
<txp:if_search>
<txp:article limit="9999" />
<txp:else />
...
</txp:if_search>
Edit: but probably <txp:article Closed="" />
will do the job just fine?
OT for Jukka: the match
attribute of if_custom_field
accepts a potentially unsafe regexp pattern
match type.
Last edited by etc (2013-09-30 09:44:04)
Offline