KSP*_*SPR 4 conditional expressionengine
我有一个条件外的频道条目标签,应该确定一个频道是否有1.条目,2.过期条目,3.封闭条目:我试过{if channel_short_name == "news"}
但不知何故,无论条目是关闭还是过期,它都会返回包装内容.我有条件的原因是在频道标签之外是因为我不想重复h2标签.
{if there are a displayable entries in the "news" channel, display this whole package.}
<h2>News</h2>
<hr />
{exp:channel:entries channel="news" limit="2"}
<div class="entry panel">
<h3>{title}</h3>
{news_text}
{if news_full OR news_bild}
<div id="{entry_id}" class="toggleDiv">
{news_full}
{exp:ce_img:single src="{news_bild}" max_width="346" smart_scale="yes" alt="{name_orig}"}
</div>
<p><a class="show_hide" rel="#{entry_id}" href="#">Mehr…</a></p>
{/if}
</div>
{/exp:channel:entries}
{/if}
Run Code Online (Sandbox Code Playgroud)
这让我想到另一个问题:
是否可以将过期的条目设置为"已关闭"?
最简单的选择是将标题标记移动到仅与第一个条目一起显示的条件.如果没有结果,则{exp:channel:entries}标签将不生成任何输出.
{exp:channel:entries channel="news" limit="2"}
{if count == '1'}
<h2>News</h2>
<hr />
{/if}
<div class="entry panel">
<h3>{title}</h3>
{news_text}
{if news_full OR news_bild}
<div id="{entry_id}" class="toggleDiv">
{news_full}
{exp:ce_img:single src="{news_bild}" max_width="346" smart_scale="yes" alt="{name_orig}"}
</div>
<p><a class="show_hide" rel="#{entry_id}" href="#">Mehr…</a></p>
{/if}
</div>
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)
你想要关闭过期的条目有什么特别的原因吗?除非您使用show_expired = 'yes'所有过期的条目,否则它们的行为就像它们已经关闭一样.