Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-12-05 19:45:38
- Ray
- Member
- Registered: 2004-03-02
- Posts: 154
Pagination suggestions
I’m looking for some suggestions on how to best handle pagination based on section and issue#.
The site has 14 articles posted once every second month. Articles are posted to one of three sections (local, national, international). Never the same number of articles posted to any one section with each issue.
We would like the landing page for each section to display a list of all articles posted to that section and sorted by issue number. An example would look something like…
The LOCAL section (url = thesite.com/local/)
ISSUE 49
local-story A
local-story B
local-story C
ISSUE 48
local-story D
local-story E
local-story F
local-story G
ISSUE 47
etc etc etc
The NATIONAL section would look similar… (url = thesite.com/national/)
ISSUE 49
national-story a
nationa-story b
national-story c
national-story d
national-story e
ISSUE 48
national-story f
national-story g
national-story h
The default custom article limits the article count per page to ten. More often than not this breaks up the last issue and puts part of the issue on one page (bottom) and the rest of the issue on the next page (top). We need to determine the number of SECTIONS each page displays… not the number of articles.
We don’t want to use categories as they are being used for an entirely different purpose.
Each article has a custom field to indicate the issue number.
Offline
#2 2006-12-08 01:00:10
- Ray
- Member
- Registered: 2004-03-02
- Posts: 154
Re: Pagination suggestions
Bump
Offline
#3 2006-12-09 19:50:07
- Ray
- Member
- Registered: 2004-03-02
- Posts: 154
Re: Pagination suggestions
Tilt
Offline
#4 2006-12-09 21:45:18
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Pagination suggestions
Well don’t ask such difficult questions then… ;)
I’ve been thinking about this, just haven’t come up with a solution so far (and I’m not sure that I ever will…).
Did you create this article list with <txp:if_different>
?
And with this:
We need to determine the number of SECTIONS each page displays… not the number of articles.
did you actually mean ‘issues’ instead of ‘sections’?
Offline
Re: Pagination suggestions
very rough and ugly pseudo code:
<txp:php>
$pg = intval(gps('pg')); #current page number;
if ($pg > 0) $pg--;
$ipp = 3; #issues per page;
$issues = safe_rows('query returning issue numbers ORDER DESC LIMIT $ipp*$pg, $ipp');
$_GET['pg'] = 0; # forget page number
foreach ($issues as $issue) {
#loop through the issues we want displayed on this page
echo article(array('custom_1' => $issue));
}
# try to fix pagination
$itot = safe_count('number of issues');
$atot = safe_count('number of articles');
article(array('pgonly' => 1, 'pageby' => intval($atot/$itot)));
</txp:php>
Last edited by ruud (2006-12-11 18:46:29)
Offline
#6 2006-12-11 01:05:04
- Ray
- Member
- Registered: 2004-03-02
- Posts: 154
Re: Pagination suggestions
Did you create this article list with
<txp:if_different>
?
Page tags
<txp:if_individual_article>
<txp:article form="xyz" />
<txp:else />
<dl>
<txp:article sort="(custom_3+0) desc, Posted asc" form="archive_list" />
</dl>
</txp:if_individual_article>
The xyz form
<txp:if_individual_article>
<h1><txp:title /></h1>
<h2><txp:custom_field name="sub_title" /></h2>
<h3 class="sub_title">by ~ <txp:custom_field name="author_name" /></h3>
<txp:body />
</txp:if_individual_article>
did you actually mean ‘issues’ instead of ‘sections’?
Correct. Good call. We need to determine the number of ISSUES each page displays not the number of articles.
Offline
#7 2006-12-11 16:43:59
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Pagination suggestions
Ray wrote:
The xyz form
I’d rather see the archive_list form if you don’t mind?
Edit: BTW does Ruud’s script do what you want?
Last edited by els (2006-12-11 16:45:14)
Offline
Pages: 1