Blog: limiting number of posts per page
5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 22, 2009 (RSS)
By NigelGordijk - May 22, 2009
I'm putting together a blog using CMSB: http://www.yallaf1.com/blog.php.
The first page of this section only needs to show the five most recent posts. Clicking on a headline link - for, say, http://www.yallaf1.com/blogDetail.php?1 - should only show a single post.
Does anyone know how to set up the blog - or any other multi-page section, for that matter - so that I can limit the number of (a) headlines that appear and (b) the number of posts that appear, whether it's five or only one?
Thanks!
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] Blog: limiting number of posts per page
By Damon - May 22, 2009
To limit the number of posts that appear in an index use this code in to top part of your page:
'perPage' => '5',
Next, it appears that your blog.php and blogDetail.php pages are almost the indentical.
Does the blogDetail.php have a foreach loop for the content? It shouldn't so this would explain the additional article on the page.
Use the Code Generator for the blog to generate single page code to confirm the correct code.
To make it easy to check your blog post links are linking to the right page, try adding the "title" to the Filename Fields:
Admin > Section Editors > click modify for the Blog seciton, then click on the Viewer Urls.
I hope this helps.
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Damon] Blog: limiting number of posts per page
By NigelGordijk - May 22, 2009
Please can you point me to a tutorial that explains how I link to the rest of the posts? i.e. the index page for earlier articles.
regards,
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] Blog: limiting number of posts per page
By Damon - May 22, 2009
The best way to link to earlier articles is to setup prev and next links at the bottom of the blog index page.
When you generate code for the Blog section index (List page), in the View Options under "How Many", select the radio button for Show "5" records per page with prev & next page links.
This will generate the code to use. This is the part of the code that will generate the previous and next page links:
<?php if ($blogMetaData['prevPage']): ?>
<a href="<?php echo $blogMetaData['prevPageLink'] ?>"><< prev</a>
<?php else: ?>
<< prev
<?php endif ?>
- page <?php echo $blogMetaData['page'] ?> of <?php echo $blogMetaData['totalPages'] ?> -
<?php if ($blogMetaData['nextPage']): ?>
<a href="<?php echo $blogMetaData['nextPageLink'] ?>">next >></a>
<?php else: ?>
next >>
<?php endif ?>
Let me me know how this works out for you.
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Damon] Blog: limiting number of posts per page
By NigelGordijk - May 22, 2009
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net