我使用文本框多数据类型创建了关键字的属性类型。
然后将关键字分隔成以逗号分隔的单词或短语列表。
我已将关键字包装在 A 标记中,带有链接到我的搜索页面的 href,并包含关键字的值,以便具有相同关键字的所有节点都将显示在我的搜索中。
我想添加一个选项,用户可以从带有关键字值的复选框中进行选择,然后提交搜索,以便所有选中的关键字都包含在搜索中。
我需要帮助弄清楚如何获取关键字复选框列表的选中值以提交并在我的搜索页面上显示结果。
这是我到目前为止所拥有的,它没有提交,我找不到在哪里添加复选框的值:
<xsl:if test="string($currentPage/keywords) != ''">
<!-- get the contents of the textbox multiple, with commas -->
<xsl:variable name="textWithBrs" select="umbraco.library:ReplaceLineBreaks($currentPage/keywords)"/>
<!-- replace commas with pipes so you can use Split -->
<xsl:variable name="textWithPipes" select='umbraco.library:Replace($textWithBrs, ", ", "|")'/>
<!-- split into an array of items and output as unordered list -->
<xsl:variable name="items" select="umbraco.library:Split($textWithPipes, '|')"/>
<ul>
<xsl:for-each select="$items/value">
<li>
<input type="checkbox" value="true" keyword="{.}" id="{.}" name=""/>
<a>
<xsl:attribute name="href"> <xsl:text disable-output-escaping="yes">/imagery/image-search.aspx
<![CDATA[?]]>
search=</xsl:text> <xsl:value-of select="." /> </xsl:attribute>
<xsl:attribute name="title"> <xsl:value-of select="."/> </xsl:attribute>
<xsl:value-of select="."/> </a> </li>
</xsl:for-each>
</ul>
<input type="submit" value="Search" id="btnSearchBottom" name="" onclick="location.href='/imagery/image-search.aspx?search=otbra'" />
</xsl:if>
任何帮助将不胜感激。
干杯,合资企业
我已经进行了一些编辑,现在让它半工作。但是,我的 Umbraco 模板有一个包含我的内容的表单。我认为这是导致一些问题的原因。
在我的测试中,我有一个包装我的 XSL 代码的表单。当我单击“提交”按钮时,没有任何反应,但如果我有相同代码的副本,则第二个复选框列表将能够提交。此外,当我进行多项选择时,搜索结果会尝试查找不返回任何结果的“一,二”(/image-search.aspx?search=one&search=two)。它应该搜索“一二”(/image-search.aspx?search=one%20two)。
我的重复形式的代码:
<div style="display:none;">
<form name="input" action="/imagery/image-search.aspx" method="get">
<ul>
<xsl:for-each select="$items/value">
<li>
<input type="checkbox" name="search" value="{.}"/>
<a href="/imagery/image-search.aspx?search={umbraco.library:UrlEncode(.)}" title="{.}"> <xsl:value-of select="."/> </a> </li>
</xsl:for-each>
</ul>
<input type="submit" value="Submit"/>
</form>
</div>
<div>
<form name="input" action="/imagery/image-search.aspx" method="get">
<ul>
<xsl:for-each select="$items/value">
<li>
<input type="checkbox" name="search" value="{.}"/>
<a href="/imagery/image-search.aspx?search={umbraco.library:UrlEncode(.)}" title="{.}"> <xsl:value-of select="."/> </a> </li>
</xsl:for-each>
</ul>
<input type="submit" value="Submit"/>
</form>
</div>
Then I tried the following code, which didn't require to wrap the list in a form. Again multiple selections don't work, but also the only result returned is the first input value in the list (in this case 'one').
<ul id="checkboxes">
<xsl:for-each select="$items/value">
<li>
<input id="{.}" type="checkbox" name="search" value="{.}"/>
<a href="/imagery/image-search.aspx?search={umbraco.library:UrlEncode(.)}" title="{.}"> <xsl:value-of select="."/> </a> </li>
</xsl:for-each>
</ul>
<input name="searchbutton" class="button" value="Search" type="reset" onClick="location.href='/imagery/image-search.aspx?search=' + $('#checkboxes input').attr('value')" />
So I need help with which option to use, and how to include multiple selections in the search result.