Page 1 of 1
SOLVED : Paginating News
Posted: Wed Nov 07, 2007 12:03 am
by Eskymo
Another simple question for you experts out there...
I want my news page to paginate...I've used this within my news page template:
{news moretext="read more" detailpage="newsdetail" pagelimit="5"}
and so the pagelimit is set to 5 - it does indeed show only 5 news stories, but even though I've put in 6 test articles no pagination appears to show the 6th news story on another page...is there code that I need to put in place to do this?
Re: Paginating News
Posted: Wed Nov 07, 2007 7:26 am
by cyberman
Default templates contains code for pagination - your templates too?
{if $pagecount > 1}
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber
{/if}
{foreach from=$items item=entry}
{if $entry->formatpostdate}
{$entry->formatpostdate}
{/if}
{$entry->titlelink}
{$category_label} {$entry->category}
{if $entry->author}
{$author_label} {$entry->author}
{/if}
{if $entry->summary}
{eval var=$entry->summary}
[{$entry->morelink}]
{else if $entry->content}
{eval var=$entry->content}
{/if}
{/foreach}
Re: Paginating News
Posted: Wed Nov 07, 2007 8:59 am
by Eskymo
including this
Code: Select all
{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
in the summary template puts pagination onto the news story I have on the homepage, so I took this out. I want the pagination to appear only once and only at the bottom of my news page.
I've just re-inserted the code so you can see what I mean...
homepage pagination on the news story on the homepage [not wanted]
http://www.techsinthecity.co.uk/devsite/
so would the best thing to do be to create a separate news summary template for the homepage? How would I call that specific template on the homepage if that is what to do?
Re: Paginating News
Posted: Wed Nov 07, 2007 9:26 am
by RonnyK
Eskymo,
from the help of the NEWS.
(optional) summarytemplate="" - Use a separate database template for displaying the article summary. This template must exist and be visible in the summary template tab of the News admin, though it does not need to be the default. If this parameter is not specified, then the current template marked as default will be used.
Without the parameter, the default template will be used. Specific calling of a template will lead to the use of that template.
So if you create a new template for the main-page, you can arrange this. Otherwise you could try inserting a (UNTESTED):
Code: Select all
{if $page_alias neq 'home'}
***
{/if}
around the summary-logic, that way it will only be shown on other pages than the one holding 'home' as alias
Ronny
Re: Paginating News
Posted: Wed Nov 07, 2007 9:27 am
by Eskymo
I think I get what you mean - will give it a go - thanks for the speedy response!
Re: Paginating News
Posted: Wed Nov 07, 2007 9:31 am
by Eskymo
GENIUS!
solved!
Re: Paginating News
Posted: Wed Nov 07, 2007 9:32 am
by RonnyK
Eskymo,
I meant around the pagination-logic, and I tested it already. It works. So you can work with a single summary-template where pagination won't be shown on the main-page.
{if $page_alias neq 'home'}
{if $pagecount > 1}
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber
{/if}
{/if}
Ronny
Re: SOLVED : Paginating News
Posted: Wed Nov 07, 2007 9:35 am
by Eskymo
Well I've created a separate template and that works too...it also gives me the option of styling the news page slightly differently and adding dividers between each summary...but I like your simple solution too - will add that to my 'top tips list' spreadsheet for next time I do a site with cmsms.
I love this CMS!
Re: SOLVED : Paginating News
Posted: Wed Nov 07, 2007 10:10 am
by RonnyK
Eskymo,
another trick to style NEWS differently, is making them odd/even. This will cycle the styling.
News template:
{foreach from=$items item=entry key=j}
{if $j % 2 == 1}
{else}
{/if}
CSS:
.NewsSummary {
margin:5px 0px;
}
.NewsSummary_odd {
margin:5px 0px;
background: #99B3E5;
}
Ronny
Re: SOLVED : Paginating News
Posted: Wed Nov 07, 2007 10:15 am
by Eskymo
I did wonder how that would be done - so I could alternate the background colours using this...cool!
Thanks
E
Re: SOLVED : Paginating News
Posted: Wed Nov 07, 2007 10:19 am
by RonnyK
You could style whatever you want, I just put the background in as an example. You get a different class, so style what you want.
Ronny
Re: SOLVED : Paginating News
Posted: Wed Nov 07, 2007 10:24 am
by Eskymo
love it!
thanks