Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[SOLVED] search results
Hi guys
I am trying to customise some urls in the search results. Basically I do not want to include the urls of individual articles in sections which only have one article. (this works). But would also like to not include/change a url in a section which only has 2 articles. The schema the site is on is section/title
on a txp: 4.6.2
Currently I have this (stripped from most html) in the search_results
form.
<txp:hide>works</txp:hide>
<txp:if_article_section name="s1,s2">
<a href="<txp:site_url /><txp:section />/"><txp:section title="1" /></a>
<txp:search_result_excerpt />
<a href="<txp:site_url /><txp:section />/"><txp:site_url /><txp:section />/</a>
<txp:else />
<txp:hide>does not work as the url of the individual article with id 1 is included in the search results.
Preferred url is <txp:site_url />about/"></txp:hide>
<txp:if_article_section name="about">
<txp:if_article_id id="1">
<a href="<txp:site_url />about/">About</a>
<txp:search_result_excerpt />
<a href="<txp:site_url />about/"><txp:site_url />about/</a>
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
<txp:search_result_excerpt />
<txp:permlink><txp:permlink /></txp:permlink>
</txp:if_article_id>
</txp:if_article_section>
<txp:else />
<txp:hide>works</txp:hide>
<txp:permlink><txp:title /></txp:permlink>
<txp:search_result_excerpt />
<txp:permlink><txp:permlink /></txp:permlink>
</txp:if_article_section>
I’ve been working on this for a few hours and – for the life of me – I can not see why it is not working. Any help will save some of the few remaining hairs on my head.
>Edited to add: I think that the logic is wrong but I can not see any other way.
<txp:if_article_section name="s1,s2">
<txp:else />
<txp:if_article_section name="about">
<txp:if_article_id id="1">
<txp:else />
</txp:if_article_id>
</txp:if_article_section>
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_section>
Last edited by colak (2018-04-11 18:12:49)
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: [SOLVED] search results
Does this do what you want?
<txp:variable name="static_sections">s1,s2</txp:variable>
<txp:if_article_section name="about">
<txp:if_article_id id="1">
<!-- special case article -->
<a href="<txp:site_url />about/">About</a>
<txp:else />
<!-- other about article -->
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_id>
<txp:else />
<txp:if_article_section name='<txp:variable name="static_sections />'>
<!-- static section -->
<a href="<txp:site_url /><txp:section />"><txp:title /></a>
<txp:else />
<!-- regular section -->
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_section>
</txp:if_article_section>
Maybe?
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] search results
What you can also do is:
<txp:variable name="static_sections">s1,s2</txp:variable>
<!-- default output -->
<txp:variable name="search_url"><txp:permlink /></txp:variable>
<txp:variable name="search_title"><txp:title /></txp:variable>
<!-- override for static sections -->
<txp:if_article_section name='<txp:variable name="static_sections />'>
<txp:variable name="search_url"><txp:site_url /><txp:section />/</txp:variable>
<txp:variable name="search_title"><txp:section title="1" /></txp:variable>
</txp:if_article_section>
<!-- override for special case -->
<txp:if_article_id id="1">
<txp:variable name="search_url"><txp:site_url />about/</txp:variable>
<txp:variable name="search_title">About</txp:variable>
</txp:if_article_id>
<!-- output search entry -->
<a href="<txp:variable name="search_url" />"><txp:variable name="search_title" /></a>
<txp:search_result_excerpt />
Location: <txp:variable name="search_url" />
This approach can help if your conditions get increasingly complex and you want to avoid lots of repetition.
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] search results
jakob wrote #310898:
Does this do what you want?
<txp:variable name="static_sections">s1,s2</txp:variable>...
Maybe?
That was it!!! Thanks so much Julian!!! Here’s the complete code
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1