Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Seach results and empty excerpts
Hi, TXP folks :)
Due to a visual organisation of search results in order to distinguish the articles titles vs the search excerpts, if only a title matches a search term no excerpt is displayed and my (attempted) structure is broken.
So I do that:
<txp:php> $some = search_result_excerpt(array()); echo( ($some ? $some : '(…)') ); </txp:php>
Is there better solutions?
Last edited by Pat64 (2013-11-05 10:10:20)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Seach results and empty excerpts
Here’s a possible native way but I think that your way should be lighter to the system:)
<txp:if_search_results>
<txp:variable name="onlyone" value='<txp:search_result_count />' />
<txp:if_variable name="onlyone" value="1">
do what you want
<txp:else />
more results
</txp:if_variable>
</txp:if_search_results>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Seach results and empty excerpts
Hey Yiannis, that’s a very good exemple of a result with only native tags!
Don’t know if a new <txp:if_search_result_excerpt>
tag will be useful for everyone?
Thanks lot for your reply.
Cheers,
Last edited by Pat64 (2013-11-05 18:48:00)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Seach results and empty excerpts
Hi Pat,
I reread your original post and realised that I misread it first time. Here’s the correct code.
<txp:if_search_results>
<txp:variable name="hasexcerpt" value='<txp:search_result_excerpt />' />
<txp:if_variable name="hasexcerpt" value="">
do what you want
<txp:else />
more results
</txp:if_variable>
<txp:else />
No results
</txp:if_search_results>
Re the <txp:if_search_result_excerpt>
, it can be achieved with variables but I can understand its possible usefulness as search could also be used for keywords/custom_fields etc in certain installs and – using variables is not friendly for beginners.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Seach results and empty excerpts
:)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Pages: 1