News number=1 shows 2 news items [CMSMS 1.12]

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Dorybalder
New Member
New Member
Posts: 3
Joined: Tue Aug 18, 2015 8:04 am

News number=1 shows 2 news items [CMSMS 1.12]

Post by Dorybalder »

Dear all,

For years we have been using a setup where three news blocks on the site each showed 1 news item, for the simple reason that they are all styles slightly different.

After 'upgrading' from 1.8.x to 1.12, however (which by the way we did via a complete new install and mostly manual except for the pages) a strange problem appeared.

When the parameter number=4, number=10 etc. is added in the {news} line this works fine. When we get to number=1 though, 2 items are being displayed... The same behaviour happens with the pagelimit=1 parameter.

To solve this strange issue I have these two questions. The answer to either one will be great and enough to solve my situation.

1. Is this known behaviour and is there a known fix or a location in the code of the news module itself where this is likely to be located?

2. is there a way to show the 3 top news items each slightly differently styled from within the news template itself? This is the reason why I went with the set up as described above in the first place.

Many thanks.

EDIT: the problem manifests itself regardless of the chosen news template.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: News number=1 shows 2 news items [CMSMS 1.12]

Post by Jeff »

It is a known issue and fixed for the next version.
2. is there a way to show the 3 top news items each slightly differently styled
As with Smarty and CMSms there are a hundred ways to do something. One of the simplist is to check the {foreach} @iteration (http://www.smarty.net/docs/en/language. ... oreach.tpl)

<div class="news_item {if $entry@iteration == 1}first{elseif $entry@iteration == 2}second{else}third{/if}">
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Re: News number=1 shows 2 news items [CMSMS 1.12]

Post by pwg »

Off topic a little, but great tip about {foreach} @iteration . I certainly hadn't realised that! Very helpful.

Thanks Jeff.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: News number=1 shows 2 news items [CMSMS 1.12]

Post by velden »

Workaround would be to not use a foreach loop or break the loop after first iteration.

Code: Select all

{$entry=$items[0]}
<div class="news-summary">
  <h2>$entry->title</h2>
  <p>$entry->summary</p>
</div>
Though it would be easier to just use your current template and add {break} just before the closing {/foreach} tag

Code: Select all

<!-- Start News Display Template -->
{foreach from=$items item=entry}
<div class="NewsSummary">
 ...
</div>
{break}
{/foreach}
<!-- End News Display Template -->
Post Reply

Return to “The Lounge”