【问题标题】:limit and pagination not working in expression engine exp:query限制和分页在表达式引擎 exp:query 中不起作用
【发布时间】:2012-01-04 19:49:08
【问题描述】:

这段代码有什么问题,不允许我只显示两条记录以及分页,任何高度赞赏的帮助?

{exp:channel:entries channel="article" status="open" orderby="date" sort="desc" 
 search:entry_id="{embed:entry_ids}"  dynamic="off"  limit="1" paginate="bottom"}

        {exp:query  limit="1" sql="select count(*) as recordcount  from exp_channel_data a where entry_id IN ({embed:entry_ids}) AND channel_id=8"}
             <b> {recordcount} </b> articles found for:<b> {embed:author_name} </b>
        {/exp:query}
        <br />

        {exp:query limit="2" sql="Select B.field_id_29 as article_bodysubtitle,B.field_id_27 as bodytext, B.field_id_88 as iss_rel_id, D.title as articletitle, D.url_title as ut from exp_channel_data as B INNER JOIN exp_channel_titles D ON B.entry_id=D.entry_id where B.channel_id=8 AND B.entry_id IN({embed:entry_ids})"}
            <br />
            <strong><a href="{path='article/index/{ut}'}">{articletitle}</a></strong>:
            {exp:trunchtml chars="250" inline="..."}
              {bodytext}
               <br />                        
           {/exp:trunchtml}
           <br />

          {embed="backissues/embed_iss" iss_rel_id="{iss_rel_id}"}
          <br /><br />
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}

  {/exp:query}

{/exp:channel:entries}    

【问题讨论】:

    标签: expressionengine


    【解决方案1】:

    您的最外层通道条目查询将数据集限制为仅返回一个结果。

    尝试更改limit parameter

    {exp:channel:entries ... limit="2" paginate="bottom"}
    

    当使用pagination 时,limit 参数决定了每页显示的条目数。

    【讨论】:

    • 谢谢 rjb。我不能使它成为 limit="2" 因为 search:entry_id="{embed:entry_ids} 返回一些我需要通过执行 limit="1" 来显示的值。问题是如果我使用常规选择语句我对 exp 的限制:query 有效,但是我上面的带有连接的 sql 查询在 exp:query 上没有使用 limit="2"。
    【解决方案2】:
    {exp:query  limit="2" paginate="bottom"  sql="Select B.field_id_29 as article_bodysubtitle,B.field_id_27 as bodytext, B.field_id_88 as iss_rel_id, D.title as articletitle, D.url_title as ut
          from exp_channel_data as B
          INNER JOIN exp_channel_titles D ON B.entry_id=D.entry_id 
          where B.channel_id=8 
          AND B.entry_id IN({embed:entry_ids})"}
    
          {paginate}
             <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
          {/paginate}
    
      {exp:channel:entries channel="article" status="open" orderby="date" sort="desc" 
        search:entry_id="{embed:entry_ids}"  dynamic="off" limit="1" }
    
        <strong><a href="{path='article/index/{ut}'}">{articletitle}</a></strong>:
            {exp:trunchtml chars="250" inline="..."}
              {bodytext}
               <br />
            {/exp:trunchtml}
           <br />
          {embed="backissues/embed_iss" iss_rel_id="{iss_rel_id}"}
          <br /><br />
    
      {/exp:channel:entries}
    {/exp:query}
    

    【讨论】:

    • 问题在于 ee 解析的方式。我从频道内部取出了 sql 部分,并在打开频道条目之前添加了它,它开始工作了。
    猜你喜欢
    • 2012-06-28
    • 1970-01-01
    • 2016-01-05
    • 1970-01-01
    • 2013-11-28
    • 2016-07-18
    • 1970-01-01
    • 2017-05-03
    • 1970-01-01
    相关资源
    最近更新 更多