Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2013-02-11 12:14:19

etc
Developer
Registered: 2010-11-11
Posts: 4,529
Website GitHub

Re: etc_pagination: paginate everything

I was offline, sorry Jonathan.

jstubbs wrote:

Does <txp:etc_pagination prev="Previous" next="Next" wraptag="ul" break="li" class="link-list" /> have to be inside the container tag of <txp:article>?

No, otherwise each article will generate a new pagination list. Formless <txp:article /> by itself is ok.

Getting 30 empty articles is not related with pagination, could you post the whole <txp:article /> code?

Offline

#14 2013-02-11 12:34:42

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

Sure! Sorry about the long code block!

<txp:if_article_list>

				<div class="twelve columns">	
				<txp:article limit="30">
					<article class="<txp:custom_field name='Content_type' />">

					<txp:if_custom_field name="Content_type" value="media"> 	
						<div class="six columns centered">	
							<header>
								<h1 class="headline text-center"><txp:permlink title='Permanent link for <txp:title />'><txp:title /></txp:permlink></h1>
							</header>
							<div class="entry">
								<txp:excerpt />
								<footer>
									<p class="mediadate"><txp:permlink title='Permanent link for <txp:title />' class="date icon-camera"><txp:posted /></txp:permlink></p>
								</footer>	
							</div><!-- end entry -->
						</div><!-- end six columns -->
						<div class="image">
							<txp:body />
						</div>
					<div class="line"></div>	
					</txp:if_custom_field>

					<txp:if_custom_field name="content_type" value="video"> 		
						<div class="six columns centered">
							<header>
								<h1 class="headline text-center"><a href="<txp:custom_field name="Video_link" />"><txp:title /></a></h1>
							</header>
							<div class="entry">
								<txp:body />
								<footer>
									<p class="videodate"><txp:permlink title='Permanent link for <txp:title />' class="date icon-play"><txp:posted /></txp:permlink></p>
								</footer>	
							</div><!-- end entry -->
						</div><!-- end six columns -->
						<div class="flex-video <txp:custom_field name="Video_meta" />">
							<p><txp:custom_field name="Video_embed"  escape="" /></p>
						</div><!-- end flex-video -->
					<div class="line"></div>	
					</txp:if_custom_field>

					<txp:if_custom_field name="content_type" value="blog"> 
						<div class="six columns centered">
							<header>
								<h1 class="headline text-center"><txp:permlink title='Permanent link for <txp:title />'><txp:title /></txp:permlink></h1>	
							</header>
							<div class="entry">
								<txp:body />
								<footer>
									<p class="blogdate"><txp:permlink title='Permanent link for <txp:title />' class="date icon-connection"><txp:posted /></txp:permlink></p>
								</footer>	
							</div><!-- end entry -->
						</div><!-- end six columns -->
					<div class="line"></div>		
					</txp:if_custom_field>

					<txp:if_custom_field name="content_type" value="link">
						<div class="six columns centered">
							<header>
								<h1 class="headline text-center"><a href="<txp:custom_field name="Link" />"><txp:title /></a></h1>
							</header>
							<div class="entry">
								<txp:body />
								<footer>
									<p class="linkdate"><txp:permlink title='Permanent link for <txp:title />' class="date icon-link"><txp:posted /></txp:permlink></p>
								</footer>	
							</div><!-- end entry -->
						</div><!-- end six columns -->
					<div class="line"></div>	
					</txp:if_custom_field>

					<txp:if_custom_field name="content_type" value="quote"> 
						<div class="six columns centered">
							<header>		
								<h1 class="headline text-center"><a href="<txp:custom_field name="Quote_link" />"><txp:title /></a></h1>
							</header>
							<div class="entry">
								<txp:body />
								<footer>
									<p class="author"><txp:custom_field name="Quote_author" /><txp:permlink title='Permanent link for <txp:title />' class="date icon-comment-left"><txp:posted /></txp:permlink></p>
								</footer>	
							</div><!-- end entry -->
						</div><!-- end six columns -->
					<div class="line"></div>	
					</txp:if_custom_field>

					</article>
				</txp:article>
				</div><!-- end twelve columns -->

				<div class="ten columns centered text-center">
					<div id="newer-older">
						<txp:etc_pagination prev="Previous" next="Next" wraptag="ul" break="li" class="link-list" />
					</div>	
				</div>	
			</txp:if_article_list>

Offline

#15 2013-02-11 12:38:41

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

BTW – using 4.5.4.

Offline

#16 2013-02-11 13:31:01

etc
Developer
Registered: 2010-11-11
Posts: 4,529
Website GitHub

Re: etc_pagination: paginate everything

It looks ok, but if you get only empty classes in <article class=""></article>, it means for me that <txp:custom_field name='Content_type' /> of displayed articles is empty, so nothing else is output. Could you add something, like <txp:title />, just before the first <txp:if_custom_field /> block to see what happens? You can also add <txp:newer/older /> tags inside <div id="newer-older" /> to see if they work as expected.

Offline

#17 2013-02-11 13:43:44

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

You are most likely correct Oleg, it’s a move from one template to another so its likely that there is nothing in the custom fields. I’ll investigate and report back.

Offline

#18 2013-02-11 14:20:22

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

Hi Oleg, yes you were correct that the issue was in fact that the custom field was empty and therefore nothing was being returned. Thanks for your help and this lovely little plugin! I’ll post a URL when the site is launched in the next day or two..

Offline

#19 2013-02-11 14:38:03

etc
Developer
Registered: 2010-11-11
Posts: 4,529
Website GitHub

Re: etc_pagination: paginate everything

You are welcome, thanks for kind words!

Actually, v.0.3 is in stale since few days, I guess it’s time to release it while it has a chance to be used. :) It treats special characters in url and brings more freedom in link construction.

Offline

#20 2013-03-27 16:36:10

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

Hi Oleg, on a current site the pagination needed is from an article_custom tag, and much to my chagrin I saw that etc_pagination doesn’t work with article_custom, at least I don’t see anything in the plugin help text. Any chance its supported and I missed it?

Offline

#21 2013-03-27 16:52:13

etc
Developer
Registered: 2010-11-11
Posts: 4,529
Website GitHub

Re: etc_pagination: paginate everything

Hi Jonathan, <txp:article_custom /> paginates very badly, but you can achieve it with a little help from etc_query (see here). Try to put this in your page form to paginate <txp:article_custom section="your_section" /> by 5:

<!-- count the pages -->
<txp:etc_query name="numPages" data="SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section='your_section'" />

<!-- navigation bar -->
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" />

<!-- display the appropriate page -->
<txp:article_custom section="your_section" limit="5" offset='<txp:etc_query data="{?page|0|intval.-1.*5}" globals="_GET" />' />

Last edited by etc (2013-03-30 17:13:35)

Offline

#22 2013-03-28 00:58:23

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

Thanks Oleg – I’ve given it a first go but run across probably a simple problem to resolve. Heres the code I’m using:

<!-- count the pages -->
		<txp:etc_query name="numPages" data="SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section='<txp:if_section name="news">news,blog,potw,six-innings<txp:else /><txp:section /></txp:if_section>'" />

		<txp:article_custom section='<txp:if_section name="news">news,blog,potw,six-innings<txp:else /><txp:section /></txp:if_section>' offset='<txp:etc_query data="{?page|0|intval.-1.*5}" globals="_GET" />'>

....Article stuff here....

<txp:if_article_list>
<txp:if_variable name="numPages" value="">
		<txp:else />
<div id="newer-older" class="text-center">
	<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />
</div>
</txp:if_variable>
</txp:if_article_list>

What I’m getting is no pagination output. Just the newer-older div. I’ve tried removing the <txp:if_variable name> block but that doesn’t work either. There is something in the etc_pagination call that is throwing it off.

Second issue is that the article_custom is now displaying 10 articles in an individual article page – that didn’t happen before. I guess I could add if_individual logic, but would like to understand why the etc_query tag in the article_custom call changes the output of articles….

Offline

#23 2013-03-28 08:27:04

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: etc_pagination: paginate everything

Seems the variable is not being set properly:

<txp:if_variable name="numPages" value="">
			[<txp:if_variable name="numPages" value="">: false]
			<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />
				[attribute 'pages']
				<txp:variable name="numPages" />
					[<txp:variable>: Unknown variable 'numPages']
				[/attribute]
				[attribute 'range']
				<txp:adi_if_mobile>
					[<txp:adi_if_mobile>: false]
				</txp:adi_if_mobile>
				[/attribute]
				[<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />: false]
		</txp:if_variable>

I got the article_list and individual pages sorted out, just used forms instead inside calls to article_custom and article. So now, its just list pagination.

Offline

#24 2013-03-28 09:10:12

etc
Developer
Registered: 2010-11-11
Posts: 4,529
Website GitHub

Re: etc_pagination: paginate everything

Jonathan, etc_query uses the raw MySQL syntax for DB queries, so Section='news,blog,potw,six-innings' looks for the section literally named news,blog,potw,six-innings. Try to replace the first query by

<!-- count the pages -->
<txp:etc_query name="numPages"
	data='SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section IN (<txp:if_section name="news">"news","blog","potw","six-innings"<txp:else />''<txp:section />''</txp:if_section>)' />

and then (without if_variable)

<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next"
	range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="div" class="text-center" />

Edit: you’ll probably have to replace “six-innings” by “six\-innings”, but I am not sure.

Last edited by etc (2013-03-28 09:14:34)

Offline

Board footer

Powered by FluxBB