【问题标题】:ExpressionEngine not showing when there are no comments没有评论时,ExpressionEngine 不显示
【发布时间】:2011-04-05 04:49:42
【问题描述】:

我似乎无法弄清楚为什么没有 cmets 时 ExpressionEngine 不显示消息。它现在的工作方式,当没有 cmets 时,什么都不会显示。当有一条评论时,将显示该评论。我还注意到,当没有 cmets 时,它不会在 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}

【问题讨论】:

    标签: html content-management-system expressionengine


    【解决方案1】:

    我无法对此进行测试,但您已启用 dynamic="no"url_title="{segment_4}"

    dynamic="no" 防止 URI 对博客的内容产生任何影响。当使用{segment_x} 变量指定url_title 时,这是否有任何影响,我不知道。 (这是推测)

    但是,您的代码似乎不必要地复杂,但以下内容对于单个页面条目可以正常工作:

    {exp:comment:entries sort="asc" limit="20"}
    {if no_results} There are no comments... {/if}    
    
    {comment}
    
    <p>By {name} on {comment_date format="%Y %m %d"}</p>
    
    {/exp:comment:entries}
    

    您不需要在 cmets 标签中指定 channel/url_title(假设您在单个页面条目上,我相信您来自您的帖子)。

    尝试一下,看看你是否得到想要的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      • 2012-10-14
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多