Page 1 of 1

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

Posted: Tue Aug 18, 2015 8:12 am
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.

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

Posted: Wed Aug 19, 2015 11:34 pm
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}">

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

Posted: Fri Aug 21, 2015 7:53 pm
by pwg
Off topic a little, but great tip about {foreach} @iteration . I certainly hadn't realised that! Very helpful.

Thanks Jeff.

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

Posted: Sun Aug 23, 2015 8:51 am
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 -->