当没有评论时,ExpressionEngine 不显示
我似乎无法弄清楚为什么 ExpressionEngine 在没有评论时不显示消息。现在的工作方式是,当没有评论时,不会显示任何内容。当有一条评论时,会显示该评论。我还注意到,当没有注释时,它不会执行 comment:entries 循环内的任何内容。
{exp:comment:entries channel="article" url_title="{segment_4}" orderby="{entry_date}" sort="desc" dynamic=“no”}
{if no_results}
<p>Nothing has been said yet. <a href="#leave-a-comment">Write something.</a></p>
{/if}
{comment}
<p class="comment-by">By {if "{url}" != ""}<a href="{url}">{name}</a>{if:else}{name}{/if} on {comment_date format="%Y %m, %d"}</p>
{/exp:comment:entries}
I can't seem to figure out why ExpressionEngine is not displaying the message when there are when there are no comments. The way it works now, when there are no comments nothing is displayed. When there is one comment, the comment is displayed. I also noticed when there are no comments it won't execute anything inside of the comment:entries loop.
{exp:comment:entries channel="article" url_title="{segment_4}" orderby="{entry_date}" sort="desc" dynamic=“no”}
{if no_results}
<p>Nothing has been said yet. <a href="#leave-a-comment">Write something.</a></p>
{/if}
{comment}
<p class="comment-by">By {if "{url}" != ""}<a href="{url}">{name}</a>{if:else}{name}{/if} on {comment_date format="%Y %m, %d"}</p>
{/exp:comment:entries}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法对此进行测试,但您已启用
dynamic="no"
和url_title="{segment_4}"
。dynamic="no"
防止 URI 对博客内容产生任何影响。我不知道当使用{segment_x}
变量指定url_title
时这是否有任何影响。 (这是猜测)但是,当以下内容适用于单页面条目时,您的代码似乎不必要地复杂:
您不需要在注释标记中指定channel/url_title(假设您在单页面条目上,我相信你来自你的帖子)。
尝试一下,看看是否能得到想要的结果。
I'm unable to test this, but you have
dynamic="no"
on, andurl_title="{segment_4}"
.dynamic="no"
prevents the URI from having any effect on the content of a weblog. Whether this has any effect when theurl_title
is specified using a{segment_x}
variable, I do not know. (This is speculation)However your code seems needlessly complicated, when the following will work fine for a single page entry:
You don't need to specify channel/url_title in the comments tag (assuming you are on a single page entry, which I believe you are from your post).
Try that, see if you get the desired result.