{if checkbox->value} display 1 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.
Post Reply
piphansdk
Forum Members
Forum Members
Posts: 30
Joined: Fri Jan 20, 2012 9:19 am

{if checkbox->value} display 1 news.

Post by piphansdk »

When i submit an article i have a checkbox, for important news.
I need to make an summary template, that is showing 1 article, if the checkbox is checked.

Code: Select all

{foreach from=$items item=entry} 
{if $entry->fieldsbyname.tophistorie->value}
<a class="thlink" href="{$entry->moreurl}">
<div id="thlinkholder">
<div id="thtextholder">
{$entry->title|cms_escape}
</div>
</div>
</a>
<div id="thimgholder">
<img src="{$entry->file_location}/{$entry->fieldsbyname.image->value}" height="100%" width="100%"/>
</div>
{/if}
{/foreach}
i have made this one. It is working fine, but of course, if i have 5 news with the checkbox checked, it will post all 5, and i only want one.
so if i write {news summarytemplate="template" number="1"}
it is working fine, but if the latest article havent a checked checkbox, it will post no articles :( any idea?
uniqu3

Re: {if checkbox->value} display 1 news.

Post by uniqu3 »

If you are using CMSMS 1.11.x which is using Smarty3 template engine you can look here http://www.smarty.net/docs/en/language. ... ruct.break
piphansdk
Forum Members
Forum Members
Posts: 30
Joined: Fri Jan 20, 2012 9:19 am

Re: {if checkbox->value} display 1 news.

Post by piphansdk »

Hi :) thank you for the anwser, but i am sorry, i can not understand the codes :(

can you please help me out?
uniqu3

Re: {if checkbox->value} display 1 news.

Post by uniqu3 »

Assuming tophistorie field is your checkbox?

Code: Select all

{foreach from=$items item=entry} 
{if $entry->fieldsbyname.tophistorie->value != 1}
    {continue}
{/if}
{if $entry@index > 1}
    {break}
{/if}
<a class="thlink" href="{$entry->moreurl}">
<div id="thlinkholder">
<div id="thtextholder">
{$entry->title|cms_escape}
</div>
</div>
</a>
<div id="thimgholder">
<img src="{$entry->file_location}/{$entry->fieldsbyname.image->value}" height="100%" width="100%"/>
</div>
{/if}
{/foreach}
Untested but should be close
piphansdk
Forum Members
Forum Members
Posts: 30
Joined: Fri Jan 20, 2012 9:19 am

Re: {if checkbox->value} display 1 news.

Post by piphansdk »

thank you so much, removed the {/if} and it worked like a charm :) Have a pleasant day :)
Post Reply

Return to “CMSMS Core”