我创建了一个图片库,并使用以下过滤器对页面上显示的结果进行排序:
效果很好并且按预期过滤,直到我导航到分页中的另一个页面(.aspx?page=2)并且过滤器恢复为默认选项。我需要它来保存选定的选项并相应地显示过滤结果。
这是我正在使用的 XSLT 的一个片段,如果需要,我可以发布整个 XSLT:
<xsl:variable name="FF_sortType" select="umbraco.library:RequestForm('sortType')" />
<xsl:variable name="FF_resultsPerPage" select="umbraco.library:RequestForm('resultsPerPage')" />
<xsl:variable name="FF_details" select="umbraco.library:RequestForm('details')" />
<xsl:variable name="FF_zoom" select="umbraco.library:RequestForm('zoom')" />
<!-- Filter the page results, Images per page, Most Recent/Alphabetical, Details On/Off, Zoom On/Off -->
<form action="#">
<div class="imageGalleryAlbumFilter">
<fieldset>
<label>Images per page:</label>
<select name="resultsPerPage" id="resultsPerPage" onchange="document.getElementById('BoostMasterForm').submit()" >
<option value="8">
<xsl:if test="$FF_resultsPerPage= '8'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
8 </option>
<option value="20">
<xsl:if test="$FF_resultsPerPage= '20'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
20 </option>
<option value="40">
<xsl:if test="$FF_resultsPerPage= '40'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
40 </option>
<option value="60">
<xsl:if test="$FF_resultsPerPage= '60'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
60 </option>
<option value="80">
<xsl:if test="$FF_resultsPerPage= '80'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
80 </option>
<option value="100">
<xsl:if test="$FF_resultsPerPage= '100'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
100 </option>
</select>
</fieldset>
<fieldset>
<label>Sort by:</label>
<select name="sortType" id="sortType" onchange="document.getElementById('BoostMasterForm').submit()" >
<option value="MostRecent">
<xsl:if test="$FF_sortType= 'MostRecent'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
Most recent </option>
<option value="Alphabetical">
<xsl:if test="$FF_sortType= 'Alphabetical'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
Alphabetical </option>
</select>
</fieldset>
<fieldset>
<label>Details:</label>
<select name="details" id="details" onchange="document.getElementById('BoostMasterForm').submit()" >
<option value="On">
<xsl:if test="$FF_details= 'On'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
On </option>
<option value="Off">
<xsl:if test="$FF_details= 'Off'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
Off </option>
</select>
</fieldset>
<fieldset>
<label>Zoom:</label>
<select name="zoom" id="zoom" onchange="document.getElementById('BoostMasterForm').submit()" >
<option value="On">
<xsl:if test="$FF_zoom= 'On'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
On </option>
<option value="Off">
<xsl:if test="$FF_zoom= 'Off'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
Off </option>
</select>
</fieldset>
</div>
</form>
<script type='text/javascript'>
$(document).ready(function() {
$("#resultsPerPage").change(function() {
$("#BoostMasterForm").attr("action", $(this).val());
$("#BoostMasterForm").submit();
});
$("#sortType").change(function() {
$("#BoostMasterForm").attr("action", $(this).val());
$("#BoostMasterForm").submit();
});
$("#details").change(function() {
$("#BoostMasterForm").attr("action", $(this).val());
$("#BoostMasterForm").submit();
});
$("#zoom").change(function() {
$("#BoostMasterForm").attr("action", $(this).val());
$("#BoostMasterForm").submit();
});
});
</script>
如果有人可以提供帮助,将不胜感激。
干杯,合资企业