文章条目中的条件语句影响 ExpressionEngine 中的所有后续条目
我正在构建一个通过 EE CMS 填充的幻灯片画廊。幻灯片中的每张“幻灯片”本身基本上都是一个迷你幻灯片,最多包含三张幻灯片。为了防止迷你幻灯片显示空幻灯片,我使用条件语句,这就是问题所在。如果第一个条目上没有第二张或第三张幻灯片,则会为所有后续条目隐藏它们。我需要条件来对每个条目执行检查。这是我的代码:
<!doctype html>
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<!-- TITLE & METADATA -->
<title>SparkleMasters :: Photographic Sequin Imagery</title>
<meta name="keywords" content="">
<meta name="description" content="">
<!-- CHROME AND VIEWPORT SETTINGS -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="imagetoolbar" content="no">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- FAVICON, HUMANS.TXT, STYLES & SCRIPTS REQUESTS -->
<link rel="shortcut icon" href="/_images/favicon.ico">
<link rel="author" type="text/plain" href="/humans.txt" />
<link rel="stylesheet" href="/_css/reset.css" type="text/css" media="all" title="global" charset="utf-8">
<script src="/_js/bootstrap.js?css=;js=" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="http://vjs.zencdn.net/c/video-js.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="skip_links">
<ul>
<li><a href="#navigation">Skip to the navigation</a></li>
<li><a href="#content">Skip to the content</a></li>
</ul>
</div>
<div id="page" class="clearfix">
<aside>
<header>
<h1><a href="#/">SparkleMasters :: Photographic Sequin Imagery</a></h1>
</header>
<nav>
<a name="navigation" id="navigation">Site Navigation</a>
<ul>
<li><a class="about" href="#/about">About</a></li>
<li><a class="gallery" href="#/gallery">Gallery</a></li>
<li><a class="buzz" href="#/buzz">Buzz</a></li>
</ul>
</nav>
<section id="latest-news">
<h3>Latest News</h3>
<ul>
{exp:channel:entries channel="buzz" limit="2"}
<li><a href="#/buzz">
{title}
</a></li>
{/exp:channel:entries}
</ul>
</section>
<section id="contact-us">
<h3>Contact Us</h3>
<p><a href="mailto:info@sparklemasters.com">info@sparklemasters.com</a></p>
<p>818 434 1464</p>
<p>1128 Linden Ave 3
<br>Glendale, CA 91201</p>
<form id="ajax-join-mailinglist-form" action="javascript:;">
<h3>Join Mailing List</h3>
<fieldset>
<ol>
<li class="inline">
<label for="email">Email</label>
<input type="text" class="text" id="email" name="email">
</li>
<li style="display:none;"><input type="text" id="subject" name="subject"
value="Mailing List signup from sparklemasters.com"></li>
<li class="right">
<input type="image" src="/_images/btn-join.png" id="submit" name="submit" value="Send">
</li>
</ol>
</fieldset>
</form>
<div id="note"></div>
</section>
<section id="copyright">
<p>© 2012 SparkleMasters. All rights reserved.</p>
</section>
</aside>
<div id="body">
<section id="primary">
<a name="content" id="content"></a>
<article id="gallery-detail">
<ul class="slides">
{exp:channel:entries channel="gallery" orderby="gallery_snapshot_order" sort="asc"}
<li>
<article class="sub-gallery">
<div class="caption-title">
<h2>{title}</h2>
<p>{project_type-location}</p>
</div>
<ul class="sub-slides">
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_one}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_one}
</div>
</li>
{if large_img_two}
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_two}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_two}
</div>
</li>
{/if}
{if large_img_three}
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_three}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_three}
</div>
</li>
{/if}
</ul>
</article>
</li>
{/exp:channel:entries}
</ul>
</article>
</section>
</div>
</div>
</body>
</html>
I am building a slideshow gallery that is populated via EE CMS. Each "slide" in the slideshow is basically a mini-slideshow itself, with up to three slides. To keep the mini-slideshow from showing empty slides I use conditional statements and that is where the problem arises. If there is no second or third slide on the first entry it hides them for all subsequent entries. I need the conditional to perform the check for each entry. Here is my code:
<!doctype html>
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<!-- TITLE & METADATA -->
<title>SparkleMasters :: Photographic Sequin Imagery</title>
<meta name="keywords" content="">
<meta name="description" content="">
<!-- CHROME AND VIEWPORT SETTINGS -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="imagetoolbar" content="no">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- FAVICON, HUMANS.TXT, STYLES & SCRIPTS REQUESTS -->
<link rel="shortcut icon" href="/_images/favicon.ico">
<link rel="author" type="text/plain" href="/humans.txt" />
<link rel="stylesheet" href="/_css/reset.css" type="text/css" media="all" title="global" charset="utf-8">
<script src="/_js/bootstrap.js?css=;js=" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="http://vjs.zencdn.net/c/video-js.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="skip_links">
<ul>
<li><a href="#navigation">Skip to the navigation</a></li>
<li><a href="#content">Skip to the content</a></li>
</ul>
</div>
<div id="page" class="clearfix">
<aside>
<header>
<h1><a href="#/">SparkleMasters :: Photographic Sequin Imagery</a></h1>
</header>
<nav>
<a name="navigation" id="navigation">Site Navigation</a>
<ul>
<li><a class="about" href="#/about">About</a></li>
<li><a class="gallery" href="#/gallery">Gallery</a></li>
<li><a class="buzz" href="#/buzz">Buzz</a></li>
</ul>
</nav>
<section id="latest-news">
<h3>Latest News</h3>
<ul>
{exp:channel:entries channel="buzz" limit="2"}
<li><a href="#/buzz">
{title}
</a></li>
{/exp:channel:entries}
</ul>
</section>
<section id="contact-us">
<h3>Contact Us</h3>
<p><a href="mailto:info@sparklemasters.com">info@sparklemasters.com</a></p>
<p>818 434 1464</p>
<p>1128 Linden Ave 3
<br>Glendale, CA 91201</p>
<form id="ajax-join-mailinglist-form" action="javascript:;">
<h3>Join Mailing List</h3>
<fieldset>
<ol>
<li class="inline">
<label for="email">Email</label>
<input type="text" class="text" id="email" name="email">
</li>
<li style="display:none;"><input type="text" id="subject" name="subject"
value="Mailing List signup from sparklemasters.com"></li>
<li class="right">
<input type="image" src="/_images/btn-join.png" id="submit" name="submit" value="Send">
</li>
</ol>
</fieldset>
</form>
<div id="note"></div>
</section>
<section id="copyright">
<p>© 2012 SparkleMasters. All rights reserved.</p>
</section>
</aside>
<div id="body">
<section id="primary">
<a name="content" id="content"></a>
<article id="gallery-detail">
<ul class="slides">
{exp:channel:entries channel="gallery" orderby="gallery_snapshot_order" sort="asc"}
<li>
<article class="sub-gallery">
<div class="caption-title">
<h2>{title}</h2>
<p>{project_type-location}</p>
</div>
<ul class="sub-slides">
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_one}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_one}
</div>
</li>
{if large_img_two}
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_two}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_two}
</div>
</li>
{/if}
{if large_img_three}
<li>
<a class="img-next-click" href="javascript:;"><img src="{large_img_three}" width="886" height="604" alt="{title}"></a>
<span class="caption-bar"></span>
<div class="detail-copy">
{paragraph_three}
</div>
</li>
{/if}
</ul>
</article>
</li>
{/exp:channel:entries}
</ul>
</article>
</section>
</div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您访问该页面时,渲染的输出是什么样的?您能否也发布该内容,以便我们了解 EE 如何解释您的模板?
您是否尝试过使用 {if large_img_two != ""} 使条件明确成为“if notempty”之类的东西?根据字段类型,有时空白字段仍然包含值。large_img_two、large_img_三是什么类型的字段?原生 EE 文件字段?资产字段?
When you visit the page, what does the rendered output look like? Would you be able to post that as well so we can see how EE in interpreting your template?
Have you tried using {if large_img_two != ""} to make the conditional explicitly an "if not empty kind of thing? Depending on the field type, sometimes a blank field still contains a value. What type of field is large_img_two, large_img_three? Native EE file field? Assets field? Channel Images field?