SOLVED : Paginating News

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Eskymo

SOLVED : Paginating News

Post 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?
Last edited by Eskymo on Wed Nov 07, 2007 9:31 am, edited 1 time in total.
cyberman

Re: Paginating News

Post 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}
Eskymo

Re: Paginating News

Post 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?
Last edited by Eskymo on Wed Nov 07, 2007 9:04 am, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Paginating News

Post 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
Eskymo

Re: Paginating News

Post by Eskymo »

I think I get what you mean - will give it a go - thanks for the speedy response!
Eskymo

Re: Paginating News

Post by Eskymo »

GENIUS!

solved!
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Paginating News

Post 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
Eskymo

Re: SOLVED : Paginating News

Post 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!
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: SOLVED : Paginating News

Post 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
Eskymo

Re: SOLVED : Paginating News

Post by Eskymo »

I did wonder how that would be done - so I could alternate the background colours using this...cool!

Thanks

E
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: SOLVED : Paginating News

Post 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
Eskymo

Re: SOLVED : Paginating News

Post by Eskymo »

love it!
thanks
Locked

Return to “CMSMS Core”