1

我创建了一个分页输入,在更改时将转到输入到输入中的值。

在此处输入图像描述

它将检测页面范围并允许在该范围内的这些页面之间导航。例如/image-gallery-album-1.aspx?page=3

<form type="get" onchange="return false">
  <div class="pagerUI">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <!-- previous page -->
        <xsl:if test="$page &gt; 1">
          <td class="pager-prev"><a class="previous" href="{concat('?page=', $page - 1, $qs)}" title="Previous page">&#8249;</a></td>
        </xsl:if>
        <td>Page</td>
        <td><input type="number" name="page" id="page" min="1" >
          <xsl:choose>
            <xsl:when test="$page=1">
              <xsl:attribute name="value">1</xsl:attribute>
            </xsl:when>
            <xsl:otherwise>
              <xsl:attribute name="value"> <xsl:value-of select="$currentPageNumber" /> </xsl:attribute>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:attribute name="max"> <xsl:value-of select="$numberOfPages"/> </xsl:attribute>
          </input></td>
        <td>of <xsl:value-of select="$numberOfPages"/></td>
        <!-- next page -->
        <xsl:if test="$page * $resultsPerPage &lt; count($matchedNodes)">
          <td class="pager-next"><a class="next" href="{concat('?page=', $page + 1, $qs)}" title="Next page">&#8250;</a></td>
        </xsl:if>
      </tr>
    </table>
  </div>
</form>

但是,当我将它添加到 XSLTSearch 代码时,它不起作用,因为 URL 丢失了搜索字符串。

所以不要导航到:/image-search.aspx?search=football&page=3

它导航到:/image-search.aspx?page=3没有在该页面上显示任何结果,因为它缺少显示搜索结果的搜索条件。

我尝试更改表单并包含一个“操作”,该操作将更改 URL 以包含搜索值,但我无法包含输入值,因为它是动态的。

例如,如果我在输入中输入任何值,则 URL 会更新为以下表单:/image-search.aspx?search=otbra&page=它缺少输入值的输入数字。

具有 onchange 和 action 和 method post 属性的搜索表单:

<form type="get" onchange="return false">
  <xsl:attribute name="method"> <xsl:text>post</xsl:text> </xsl:attribute>
  <xsl:attribute name="action"> <xsl:text>?search=</xsl:text> <xsl:value-of select="$search"/><xsl:text>&amp;</xsl:text>page= (input value)</xsl:attribute>

是否有一些 javascript 或某种方式来检测提交的值并将其解析为 URL 的搜索字符串?

任何援助将不胜感激。干杯,合资企业

4

1 回答 1

1

注意:正如对您帖子的评论所说,可能的问题是 $qs 变量,但是这里解释了如何在 Umbraco 中获取查询字符串值,以供参考。


在 Umbraco 中,您可以使用 XSLT 检索查询字符串值umbraco.library

因此,要检索 search 的值,您可以调用如下内容:

<xsl:variable name="searchValue" select="umbraco.library:RequestQueryString('search')"/>

这将创建一个名为 searchValue 的变量,然后您可以使用该变量在您的 url 中重新注入查询字符串值。

像这样的东西:

<a class="next" href="{concat('?page=', $page + 1, '&amp;search=', $searchValue)}" title="Next page">&#8250;</a>

有关 umbraco.library 的更多信息,请访问our.umbraco.org网站

于 2012-12-20T11:40:52.057 回答