Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-06-25 00:00:09

natalie
New Member
From: Indiana, USA
Registered: 2006-01-12
Posts: 6
Website

Pagination on search page

Hi! I’m working on a very basic template and I’m finding that the search results will not paginate on one site but it works fine on other sites. I have it set up like so…

<txp:article pgonly="1" />
<h3><txp:search_result_count text="Results Found" /></h3>
<p class="pagination">
<txp:newer>&laquo; Previous results</txp:newer> | 
<txp:older>Next 10 of <txp:search_result_count text="results" /> &raquo;</txp:older>
</p>
<dl><txp:article limit="10" sortby="Posted" sortdir="desc" /></dl>
<p class="pagination">
<txp:newer>&laquo; Previous results</txp:newer> | 
<txp:older>Next 10 of <txp:search_result_count text="results" /> &raquo;</txp:older>
</p>

This set up works on every site I’ve set up until now. I’m using the same installation of TXP on all sites. Is there something I’m missing? Something in the header, htaccess, etc?

THANKS!

Offline

#2 2007-06-25 07:35:20

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

Re: Pagination on search page

Tag trace please. :)

Offline

#3 2007-06-25 14:15:39

natalie
New Member
From: Indiana, USA
Registered: 2006-01-12
Posts: 6
Website

Re: Pagination on search page

Thanks, Mary! I had no idea I could do that. Maybe this will help…

<!-- txp tag trace: 
[SQL (0.000083): select name from txp_lang where lang='en-us' limit 1]
[SQL (0.000932): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (0.000159): select name, code, version from txp_plugin where status = 1]
[SQL (0.000101): select title from txp_section where name='search']
[SQL (0.000073): select name from txp_section where `name` like 'search' limit 1]
[SQL (0.000101): select * from txp_section where name = 'search' limit 1]
[SQL (0.000073): select host from txp_log where ip='74.141.22.24' limit 1]
[SQL (0.000070): select user_html from txp_page where name='search']
[Page: search]
<txp:output_form form="content_header" />
	[SQL (0.000139): select Form from txp_form where name='content_header']
	[Form: content_header]
	<txp:page_title/>
		[SQL (0.000079): select title from txp_section where name='search']
	<txp:feed_link flavor="atom" format="link" label="Atom" />
	<txp:feed_link flavor="rss" format="link" label="RSS" />
	<txp:css format="link" />
	<txp:if_individual_article>
		[<txp:if_individual_article>: false]
	</txp:if_individual_article>
	<txp:if_section name="archives">
		[<txp:if_section name="archives">: false]
	</txp:if_section>
	<txp:section/>
	<txp:text item="go_content" />
	<txp:text item="go_nav" />
	<txp:text item="go_search" />
	<txp:link_to_home>
		<txp:sitename/>
	</txp:link_to_home>
	<txp:section_list active_class="current" break="li" class="nav" default_title="Home" exclude="article" include_default="1" wraptag="ul" />
		[SQL (0.000101): select name, title from txp_section where name != 'default' and name not in('article') order by name]
<txp:article pgonly="1" />
	[SQL (0.000098): select name from txp_section where searchable != '1']
	[SQL (0.001758): select count(*) from textpattern where 1 and Status = 4 and Posted <= now() and (Title rlike 'velit' or Body rlike 'velit') and Section != 'search' and Section != 'archives']
<txp:search_result_count text="Results" />
<txp:output_form form="search_form" />
	[SQL (0.000122): select Form from txp_form where name='search_form']
	[Form: search_form]
	<txp:site_url/>
<txp:newer showalways="1">
</txp:newer>
<txp:older showalways="1">
</txp:older>
<txp:article limit="3" />
	[SQL (0.000095): select name from txp_section where searchable != '1']
	[SQL (0.002158): select count(*) from textpattern where 1 and Status = 4 and Posted <= now() and (Title rlike 'velit' or Body rlike 'velit') and Section != 'search' and Section != 'archives']
	[SQL (0.003596): select *, unix_timestamp(Posted) as uPosted, match (Title,Body) against ('velit') as score from textpattern where 1 and Status = 4 and Posted <= now() and (Title rlike 'velit' or Body rlike 'velit') and Section != 'search' and Section != 'archives' order by score desc limit 0, 3]
	[SQL (0.000089): select Form from txp_form where name='search_results']
	[Form: search_results]
	[article 2]
	<txp:article_image thumbnail="1" />
	<txp:permlink>
		<txp:title/>
	</txp:permlink>
	<txp:search_result_excerpt/>
	[article 3]
	<txp:article_image thumbnail="1" />
		[SQL (0.000150): select * from txp_image where id = 5]
	<txp:permlink>
		<txp:title/>
	</txp:permlink>
	<txp:search_result_excerpt/>
	[article 4]
	<txp:article_image thumbnail="1" />
		[SQL (0.000202): select * from txp_image where id = 2]
	<txp:permlink>
		<txp:title/>
	</txp:permlink>
	<txp:search_result_excerpt/>
<txp:output_form form="content_secondary" />
	[SQL (0.000121): select Form from txp_form where name='content_secondary']
	[Form: content_secondary]
	<txp:if_individual_article>
		[<txp:if_individual_article>: false]
		<txp:site_slogan/>
	</txp:if_individual_article>
	<txp:if_section name="search">
		[<txp:if_section name="search">: true]
	</txp:if_section>
	<txp:if_section name="about">
		[<txp:if_section name="about">: false]
	</txp:if_section>
	<txp:if_individual_article>
		[<txp:if_individual_article>: false]
	</txp:if_individual_article>
	<txp:if_section name="search">
		[<txp:if_section name="search">: true]
		<txp:category_list active_class="current" break="li" label="Categories" labeltag="h2" this_section="0" type="article" wraptag="ol" />
			[SQL (0.000124): select name, title from txp_category where type = 'article' and name not in('default','root')  order by name]
	</txp:if_section>
	<txp:if_section name=",archives">
		[<txp:if_section name=",archives">: false]
	</txp:if_section>
<txp:output_form form="content_footer" />
	[SQL (0.000111): select Form from txp_form where name='content_footer']
	[Form: content_footer]
	<txp:link_to_home>
		<txp:sitename/>
	</txp:link_to_home>
	<txp:feed_link label="RSS" />
	<txp:feed_link flavor="atom" label="Atom" />
	<txp:section_list active_class="current" break="li" class="footer_nav" default_title="Home" exclude="article" include_default="1" wraptag="ul" />
		[SQL (0.000107): select name, title from txp_section where name != 'default' and name not in('article') order by name]
[ ~~~ secondpass ~~~ ]
 -->

Offline

#4 2007-06-25 17:14:45

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Pagination on search page

Add limit="3" to <txp:article pgonly="1" /> – that should fix it. From the Textbook:

Just make sure that, other than pgonly, both article tags are identical.

Offline

#5 2007-06-25 18:21:11

natalie
New Member
From: Indiana, USA
Registered: 2006-01-12
Posts: 6
Website

Re: Pagination on search page

That did it, thanks! Out of curiosity though, does anyone know why it would work without this fix on all my other sites? It makes sense now that it’s mentioned, that both article tags should match, but I wonder why only on this one site.

Count this resolved nonetheless! :)

Offline

#6 2007-06-26 21:05:35

Nic
Member
Registered: 2007-06-08
Posts: 21

Re: Pagination on search page

Just guessing, but maybe it had something to do with not explicitly setting a limit? I’m not sure, I’m pretty new at this, and that seems like something obvious so sorry if it didn’t give you any ideas.

I actually have my own sort of pagination problem; I’m searching with results that show up on the home page and the paginating just takes me to the second page of home page articles, not the second page of results. I’ve put a tag trace below in case that would help.


<!-- txp tag trace: 
[SQL (0.000941): select name from txp_lang where lang='en-us' limit 1]
[SQL (0.008397): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (0.011307): select name, code, version from txp_plugin where status = 1]
[SQL (0.003555): select name, html as type from txp_prefs where event = 'permlinks' AND html <> 'gbp_partial']
[SQL (0.000864): select * from txp_section where name = 'default' limit 1]
[SQL (0.000895): insert into txp_log set `time`=now(),page='/mediaaccess/?q=low',ip='127.0.0.1',host='127.0.0.1',refer='',status='200',method='GET']
[SQL (0.002166): select REPLACE(name, 'gbp_permanent_links_', '') AS id from txp_prefs where `event` = 'permlinks' AND `name` REGEXP '^gbp_permanent_links_.{13}$']
[SQL (0.000789): select user_html from txp_page where name='home']
[Page: home]

<snip>

<txp:if_search>
	[<txp:if_search>: true]
</txp:if_search>
<txp:if_search>
	[<txp:if_search>: true]
	<txp:article limit="5" form="homepage" searchsticky="1" pgonly="1" />
		[SQL (0.000894): select name from txp_section where searchable != '1']
		[SQL (0.074080): select count(*) from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'low' or Body rlike 'low') and Section != 'archive']
	<txp:search_result_count text="Results" />
</txp:if_search>
<txp:article limit="5" form="homepage" searchsticky="1" />
	[SQL (0.000961): select name from txp_section where searchable != '1']
	[SQL (0.074186): select count(*) from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'low' or Body rlike 'low') and Section != 'archive']
	[SQL (0.082971): select *, unix_timestamp(Posted) as uPosted, match (Title,Body) against ('low') as score from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'low' or Body rlike 'low') and Section != 'archive' order by score desc limit 0, 5]
	[SQL (0.000658): select Form from txp_form where name='search_results']
	[Form: search_results]
	[article 1]
	<txp:permlink>
		<txp:title/>
	</txp:permlink>
	<txp:search_result_excerpt/>
	<txp:permlink>
		<txp:permlink/>
	</txp:permlink>
	<txp:posted/>

<snip>

<txp:if_search>
	[<txp:if_search>: true]
	<txp:older>
		<txp:search_result_count text="results" />
	</txp:older>
	<txp:newer>
	</txp:newer>
</txp:if_search>
<txp:output_form form="footer" />
	[SQL (0.000731): select Form from txp_form where name='footer']
	[Form: footer]
	<txp:gbp_disable_permlinks>
		<txp:site_url/>
		<txp:site_url/>
		<txp:feed_link label="RSS" />
		<txp:feed_link flavor="atom" label="Atom" />
	</txp:gbp_disable_permlinks>
[ ~~~ secondpass ~~~ ]
 -->

Offline

#7 2007-06-27 02:52:11

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

Re: Pagination on search page

Nic: It is because your pagination tags occur after your default page’s article tag, which you have set to always appear.

Offline

#8 2007-06-27 19:27:56

Nic
Member
Registered: 2007-06-08
Posts: 21

Re: Pagination on search page

Pardon? I’m confused. If I want to paginate the search, don’t I need to have pagination tags like older and newer? If I include them in an if_search, they still point to the home page’s Page 2. I’m not using a special Search section.

Offline

#9 2007-06-28 18:06:40

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

Re: Pagination on search page

Can you show all of your page’s contents please?

Offline

#10 2007-06-28 18:11:37

Nic
Member
Registered: 2007-06-08
Posts: 21

Re: Pagination on search page

Sure:

 
<!-- txp tag trace: 
[SQL (0.000962): select name from txp_lang where lang='en-us' limit 1]
[SQL (0.014135): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (0.010227): select name, code, version from txp_plugin where status = 1]
[SQL (0.001235): select name, html as type from txp_prefs where event = 'permlinks' AND html <> 'gbp_partial']
[SQL (0.000806): select * from txp_section where name = 'default' limit 1]
[SQL (0.003481): insert into txp_log set `time`=now(),page='/mediaaccess/?q=search',ip='127.0.0.1',host='127.0.0.1',refer='',status='200',method='GET']
[SQL (0.002077): select REPLACE(name, 'gbp_permanent_links_', '') AS id from txp_prefs where `event` = 'permlinks' AND `name` REGEXP '^gbp_permanent_links_.{13}$']
[SQL (0.028542): select user_html from txp_page where name='home']
[Page: home]
<txp:page_title/>
<txp:feed_link flavor="atom" format="link" label="Atom" />
<txp:feed_link flavor="rss" format="link" label="RSS" />
<txp:if_search>
	[<txp:if_search>: true]
	<txp:css format="link" n="default" />
</txp:if_search>
<txp:text item="go_content" />
<txp:text item="go_nav" />
<txp:text item="go_search" />
<txp:if_search>
	[<txp:if_search>: true]
	<txp:link_to_home>
		<txp:sitename/>
	</txp:link_to_home>
	<txp:output_form form="top_navigation" />
		[SQL (0.022142): select Form from txp_form where name='top_navigation']
		[Form: top_navigation]
		<txp:gbp_disable_permlinks>
			<txp:section_list include_default="1" default_title="Home" sections="press, about" break="li" />
				[SQL (0.001588): select name, title from txp_section where name in ('press','about') order by field(name, 'press','about')]
		</txp:gbp_disable_permlinks>
		<txp:site_url/>
		<txp:search_input label="" wraptag="" />
			[SQL (0.000505): select form from txp_form where `name` = 'search_input' limit 1]
	<txp:page_title/>
</txp:if_search>
<txp:output_form form="sidebar_navigation" />
	[SQL (0.000560): select Form from txp_form where name='sidebar_navigation']
	[Form: sidebar_navigation]
	<txp:category_list section="issues" break="li" wraptag="ul" categories="media-ownership, network-neutrality, open-access, lpfm, public-interest, broadcast-free-speech, civil-rights" />
		[SQL (0.001462): select name, title from txp_category where type = 'article' and name in ('media-ownership','network-neutrality','open-access','lpfm','public-interest','broadcast-free-speech','civil-rights') order by field(name, 'media-ownership','network-neutrality','open-access','lpfm','public-interest','broadcast-free-speech','civil-rights')]
	<txp:site_url/>
	<txp:site_url/>
	<txp:site_url/>
	<txp:site_url/>
	<txp:article_custom section="about" sort="Title asc" limit="99" form="sidebar_links" />
		[SQL (0.019185): select *, unix_timestamp(Posted) as uPosted from textpattern where 1 and Status = 4 and Posted <= now() and Section = 'about' order by Title asc limit 0, 99]
		[SQL (0.003012): select Form from txp_form where name='sidebar_links']
		[Form: sidebar_links]
		[article 258]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 261]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 262]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 257]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 256]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 259]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 260]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		[article 263]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
<txp:if_search>
	[<txp:if_search>: true]
</txp:if_search>
<txp:if_search>
	[<txp:if_search>: true]
	<txp:article limit="5" form="homepage" searchsticky="1" pgonly="1" />
		[SQL (0.000834): select name from txp_section where searchable != '1']
		[SQL (0.216342): select count(*) from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'search' or Body rlike 'search') and Section != 'archive']
	<txp:search_result_count text="Results" />
</txp:if_search>
<txp:if_search>
	[<txp:if_search>: true]
	<txp:article form="homepage" searchsticky="1" />
		[SQL (0.000971): select name from txp_section where searchable != '1']
		[SQL (0.227543): select count(*) from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'search' or Body rlike 'search') and Section != 'archive']
		[SQL (0.572317): select *, unix_timestamp(Posted) as uPosted, match (Title,Body) against ('search') as score from textpattern where 1 and Status >= 4 and Posted <= now() and (Title rlike 'search' or Body rlike 'search') and Section != 'archive' order by score desc limit 0, 10]
		[SQL (0.001056): select Form from txp_form where name='search_results']
		[Form: search_results]
		[article 252]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 256]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 228]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 7]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 11]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 29]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 43]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 47]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 58]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
		[article 65]
		<txp:permlink>
			<txp:title/>
		</txp:permlink>
		<txp:search_result_excerpt/>
		<txp:permlink>
			<txp:permlink/>
		</txp:permlink>
		<txp:posted/>
	<txp:newer>
	</txp:newer>
	<txp:older>
		<txp:search_result_count text="results" />
	</txp:older>
</txp:if_search>
<txp:output_form form="footer" />
	[SQL (0.000742): select Form from txp_form where name='footer']
	[Form: footer]
	<txp:gbp_disable_permlinks>
		<txp:site_url/>
		<txp:site_url/>
		<txp:feed_link label="RSS" />
		<txp:feed_link flavor="atom" label="Atom" />
	</txp:gbp_disable_permlinks>
[ ~~~ secondpass ~~~ ]
 -->

Offline

#11 2007-06-28 18:22:35

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

Re: Pagination on search page

Okay, so your older tag is linking to ?pg=2 instead of something like ?q=search&pg=2?

Where is your regular homepage content? I only see two article tags being used, and both are inside if_search conditionals.

The@older@ and newer tags depend upon the most recent article tag used for their data, so when something goes wrong with them we need to look at what article tags are being used and how.

Offline

#12 2007-06-28 18:42:55

Nic
Member
Registered: 2007-06-08
Posts: 21

Re: Pagination on search page

Yes, it’s exactly how you said with the older tag. The way I have it right now is that the first if_search sets the article numbering, and I would show the search results in the second if_search, otherwise the else shows the regular homepage content. I should have probably included this page code earlier, because with the tag trace you didn’t see it:

<div id="content">
		<txp:if_search><!-- This part tallies search results -->
<txp:article limit="5" form="homepage" searchsticky="1" pgonly="1" />
		<h3><a name="search-results"><txp:search_result_count text="Results" /></a></h3>
		</txp:if_search>

	<txp:if_search><!-- Displays the search -->
<txp:article form="homepage" searchsticky="1" />
	<p><txp:newer>&laquo; Previous results</txp:newer> | 
<txp:older>Next 10 of <txp:search_result_count text="results" /> &raquo;</txp:older></p>	

		<txp:else /><!-- Otherwise, it's the home page -->
<txp:article limit="5" form="homepage" searchsticky="1" />
	<p><txp:older><txp:text item="older" /></txp:older> 
			<txp:newer><txp:text item="newer" /></txp:newer></p>
	</txp:if_search>

	</div>

I suppose having two if_searches is a little unnecessary, since it looks like I can just combine them anyhow, but would that fix the problem? And I’m also guessing that the search numbering isn’t correct because the searched article content has a different limit.

Offline

Board footer

Powered by FluxBB