【问题标题】:Pagination not working on exp:search:search_results in expression engine分页不适用于表达式引擎中的 exp:search:search_results
【发布时间】:2012-01-04 20:28:14
【问题描述】:

分页链接在表达式引擎exp:搜索结果中不起作用。单击分页链接时页面不显示新结果。

 {exp:search:total_results}</b>Result(s) for <b>{exp:search:keywords} 
      {exp:search:search_results entry_id={entry_id}  
        switch="#000000|#003300"  status="Open" 
        dynamic="off"  orderby="date" sort="desc"} 

    {exp:search:search_results switch="resultRowOne|resultRowTwo" paginate="bottom"    limit="2"}

        <?php $articlePath = "article";?>
        {related_entries id="article_feature"}

          {if title == "Bay Blog"}<?php $articlePath = "blog";?>  
        {/related_entries} 

          <b><a href="{title_permalink="/blog/"}">{title}</a></b> from <em>{related_entries id="article_feature"}{title} {/related_entries}</em><br/>
          {if:else}

          <b><a href="{title_permalink="/article/"}">{title}</a></b> from <em>{related_entries id="article_feature"}{title} {/related_entries}</em><br/>
          {/if}     

          {exp:trunchtml chars="250" inline="..."}
                  {article_body}
           {/exp:trunchtml}
           {related_entries id="article_issue"}
            <a href="/issue/{entry_id}"> [ {title}] </a> {/related_entries}
            <br><br>
          {if no_results}
            Sorry!, Search result found!
        {/if} 
   {/exp:search:search_results}
{paginate}
        <div class='paginate'>
            <span class='pagecount'>{page_count}</span>&nbsp;
        </div>
{paginate} 

【问题讨论】:

    标签: expressionengine


    【解决方案1】:

    返回 search results 时,在构建 URL 时使用 auto_path 变量:

    <a href="{auto_path}">{title}</a>
    

    与其他路径变量不同,此变量不需要指定模板组和模板名称。

    相反,路径将由频道管理中频道的Search Results URL setting 自动确定。

    管理 > 频道管理 > 频道 > 首选项:


    如果您使用 ExpressionEngine 的 Pages ModuleStructure 创建静态页面,以下用例也可能对您有所帮助:

    {if page_url == ""}
        // If the Search Result is a Dynamic Page
        <a href="{auto_path}">{title}</a>
    {/if}
    
    {if page_url != ""}
        // If the Search Result is a Static Page
        <a href="{page_url}">{title}</a>
    {/if}
    

    您还可以测试以查看从哪个渠道获取搜索结果并有条件地对其进行操作:

    {if channel_name == "about"}
        <a href="{page_url}">{title}</a>
    {if:else}
        <a href="{auto_path}">{title}</a>
    {/if}
    

    【讨论】:

    • 通过清除缓存设置并在表达式引擎端同步模板使其工作。
    猜你喜欢
    • 1970-01-01
    • 2013-11-28
    • 2016-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多