Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2015-06-26 08:03:26
- tNr
- New Member
- Registered: 2015-05-07
- Posts: 9
Search Results Problem
Am new to txp, not a developer (not willing to hire any, just a new hobby) and am having troubles with my test site.
My search page displays results five times and I don’t know why, ie it repeats the results five times. Am using the default txp search_results form please help
Last edited by tNr (2015-06-26 08:10:18)
Offline
Re: Search Results Problem
Hello,
it looks like multiple <txp:article />
tags are somehow involved. Could you post the appropriate Page
template?
Offline
#3 2015-06-26 18:49:14
- tNr
- New Member
- Registered: 2015-05-07
- Posts: 9
Re: Search Results Problem
This is my search_results form template
<txp:if_search>
<!-- count how many results return -->
<txp:article limit="10" pgonly="1" />
<txp:if_search_results>
<!-- if search result count greater than 200 then display excessive results message, otherwise show search result count -->
<txp:if_search_results max="200">
<h3><txp:search_result_count /> <txp:text item="matching_search_request" /> ‘<txp:search_term />’…</h3>
<txp:else />
<h3><txp:text item="too_common_search_term" /> ‘<txp:search_term />’</h3>
</txp:if_search_results>
<!-- if no search results, then display no search results message -->
<txp:else />
<h3><txp:text item="no_search_matches" /></h3>
</txp:if_search_results>
<!-- display resulting articles (10 per page) -->
<txp:article limit="10">
<txp:if_first_article><ul id="article-list"></txp:if_first_article>
<li role="article" itemscope itemtype="http://schema.org/Article">
<h4 itemprop="name"><a href="<txp:permlink />" itemprop="url"><txp:title /></a></h4>
<!-- if the article has an excerpt, display that, otherwise show highlighted keywords in context of article -->
<txp:if_excerpt>
<div itemprop="description">
<txp:excerpt />
</div>
<txp:else />
<p><txp:search_result_excerpt /></p>
</txp:if_excerpt>
<p class="footnote"><txp:text item="posted" /> <time datetime="<txp:posted format='iso8601' />" itemprop="datePublished"><txp:posted /></time>, <txp:text item="author" /> <span itemprop="author"><txp:author link="1" this_section="1" /></span></p>
(<txp:search_result_url />)
</li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article>
<!-- check if there are further results and provide pagination links or disabled buttons depending on the result,
this method is more flexibile than using simple txp:older/txp:newer tags -->
<txp:if_search_results min="11">
<p id="paginator">
<txp:variable name="prev" value='<txp:older />' />
<txp:variable name="next" value='<txp:newer />' />
<txp:if_variable name="next" value="">
<span id="paginator-l" class="button disabled">← <txp:text item="prev" /></span>
<txp:else />
<a id="paginator-l" href="<txp:newer />" title="← <txp:text item="prev" />" class="button">← <txp:text item="prev" /></a>
</txp:if_variable>
<txp:if_variable name="prev" value="">
<span id="paginator-r" class="button disabled"><txp:text item="next" /> →</span>
<txp:else />
<a id="paginator-r" href="<txp:older />" title="<txp:text item="next" /> →" class="button"><txp:text item="next" /> →</a>
</txp:if_variable>
</p>
</txp:if_search_results>
</txp:if_search>
Offline
Re: Search Results Problem
Yes, this is the default search_results
form, which should be ok. But we need to see your default
page (look in Presentation/Pages
tab).
Last edited by etc (2015-06-27 09:01:02)
Offline
#5 2015-06-28 06:29:36
- tNr
- New Member
- Registered: 2015-05-07
- Posts: 9
Re: Search Results Problem
OK here
<txp:output_form form="html_head" />
</head>
<body>
<div id="blog-head">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fliud">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<txp:link_to_home />"><txp:site_name /></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<txp:section_list wraptag="ul" class="nav navbar-nav navbar-right" exclude="view" break="">
<li<txp:if_section name='<txp:section />'> class="active"</txp:if_section>>
<txp:section title="1" link="1" />
</li>
</txp:section_list>
</div>
</div>
</nav>
</div>
<div id="blog-body">
<div class="container">
<div class="row">
<div class="col-md-8" id="main">
<txp:if_individual_article>
<txp:article form="txp-starter-article-default" />
<txp:else />
<txp:if_section name="default">
<txp:else />
<txp:article form="txp-starter-section-intro" limit="1" status="5"/>
</txp:if_section>
<txp:article form="txp-starter-article-default-teaser" limit="5" sort="Posted DESC"/>
<ul class="pager">
<txp:variable name="prev" value='<txp:older />' />
<txp:variable name="next" value='<txp:newer />' />
<txp:if_variable name="prev" value="">
<txp:else />
<li class="previous"><a href="<txp:older />"><span aria-hidden="true">←</span> <txp:text item="older" /></a></li>
</txp:if_variable>
<txp:if_variable name="next" value="">
<txp:else />
<li class="next"><a href="<txp:newer />"><txp:text item="newer" /> <span aria-hidden="true">→</span></a></li>
</txp:if_variable>
</ul>
</txp:if_individual_article>
</div>
<txp:output_form form="html_foot" />
</body>
</html>
Last edited by tNr (2015-06-28 06:42:28)
Offline
#6 2015-06-28 06:48:11
- tNr
- New Member
- Registered: 2015-05-07
- Posts: 9
Re: Search Results Problem
That’s the page that handles my articles section, although it’s not named default, there’s one named default
which I no longer use and am wondering if I should delete it:
<txp:output_form form="DTD_head" />
<title><txp:page_title /></title>
<txp:output_form form="fb_page_js" />
</head>
<txp:if_section name="default">
<body id="home">
<txp:else />
<body id="<txp:section />">
</txp:if_section>
<h1><txp:sitename /> » <txp:if_individual_article><txp:if_section name=",default">Home Page<txp:else /><txp:section title="1" /></txp:if_section> » <txp:title /><txp:if_section name="article"> » <txp:posted /></txp:if_section><txp:else /><txp:if_section name=",default">Home Page<txp:else /><txp:section title="1" /></txp:if_section><txp:if_category> » <txp:category title="1" /> category listing.</txp:if_category></txp:if_individual_article></h1>
<div id="outerwrap">
<txp:output_form form="top_navigation" />
<div id="outercontent">
<div id="maincontent">
<txp:if_section name="default">
<txp:if_category>
<h2 class="categorytitle"><txp:category title="1" /> Category</h2>
</txp:if_category>
<txp:article limit="4" />
<txp:output_form form="postnavigation" />
</txp:if_section>
<txp:if_section name="about,contact">
<txp:article form="Single" listform="Single" />
</txp:if_section>
<txp:if_section name="links">
<txp:output_form form="links_page" />
</txp:if_section>
<txp:if_section name="archivescat">
<txp:output_form form="archivescat_page" />
</txp:if_section>
<txp:if_section name="archivesmonth">
<txp:output_form form="archivesmonth_page" />
</txp:if_section>
</div>
</div>
<txp:output_form form="sidebar" />
<txp:output_form form="footer" />
</div>
</body>
</html>
Offline
Re: Search Results Problem
My guess is that in search mode, <txp:article limit="4" />
in the middle of this page is calling search_results
form for each of 4 articles. Each call includes <txp:article limit="10" />
, so you get 4 copies of search results. I don’t know where the fifth copy comes from, but try to replace <txp:article limit="4" />
with
<txp:if_search />
<txp:output_form form="search_results" />
<txp:else />
<txp:article limit="4" />
</txp:if_search>
Offline
Pages: 1