Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefan 117 posts 215 karma points
    Nov 23, 2011 @ 09:56
    Stefan
    0

    XSLTsearch form not not showing on result pages

    Hi.

    I have just decided that I want to add a searchfield on top of the search results as an addition to the searchbox already present at the very top of my page.

    The problem is that the <form></form> tags does not get rendered - only the contents in between. I really can't figure out why, since I have only been editing a few settings to match my design in the xsltsearch.xslt file.

    All <input> elements gets rendered just fine.

    I have other websites which renders a <form id="aspnetForm" action="/soege-resultater.aspx?" method="post"></form> just fine around the results generated from XSLTsearch.


    This is how my modified code looks like:

            <!-- display search box at the top of the page (the search box is always present even if no search was attempted) -->
            <xsl:if test="$searchBoxLocation='TOP' or $searchBoxLocation='BOTH'">
              <div id="contact_form" class="form_field">
                
                <input name="search" type="text" class="text round_6" size="44" >
                  <xsl:attribute name="value">
                    <xsl:value-of select="$unescapedSearch"/>
                  </xsl:attribute>
                </input>
                <xsl:text>&nbsp;</xsl:text>
                <input id="submit" class="fancy" type="submit" name="search" >
                  <xsl:attribute name="value">
                    <xsl:value-of select="$dictionaryButton-Search"/>
                  </xsl:attribute>
                </input>
              </div>
            </xsl:if>

    Thanks in advance!

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 23, 2011 @ 10:36
    Douglas Robar
    0

    Hi, Stefan,

    Older versions of XSLTsearch automatically inserted form tags but that caused many problems for people who had already inserted form tags in their templates (you can't have nested form's in html) so in more recent versions I've made it explicit that you have to provide your own form tags around the search macro.

    If you don't already have a form tag around the macro you can either use a standard html form or an asp.net form (a <form> tag that includes the runat="server" parameter). 

    I generally have a separate search template that looks something like this. Customize to your needs obviously.

     

    <%@ Master Language="C#" MasterPageFile="~/masterpages/Sub-Master.master" AutoEventWireup="true" %> <asp:Content ContentPlaceHolderID="SubMasterContentPlaceHolder" runat="server"> <h4><umbraco:Item field="pageName" runat="server"/></h4> <form action="?"> <umbraco:Macro source="" searchFields="" previewFields="" searchBoxLocation="" previewType="" resultsPerPage="" previewChars="" showPageRange="0" showOrdinals="0" showScores="1" showStats="0" Alias="XSLTsearch" runat="server"> </umbraco:Macro> </form> </asp:Content>cheers,

    doug. 

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 23, 2011 @ 10:37
    Douglas Robar
    0

    Well, that worked poorly... let's try that again...

    <%@ Master Language="C#" MasterPageFile="~/masterpages/Sub-Master.master" AutoEventWireup="true" %>
     
    <asp:Content ContentPlaceHolderID="SubMasterContentPlaceHolder" runat="server">
      <h4><umbraco:Item field="pageName" runat="server"/></h4>
      <form action="?">
        <umbraco:Macro 
          source="" 
          searchFields="" 
          previewFields="" 
          searchBoxLocation="" 
          previewType="" 
          resultsPerPage="" 
          previewChars="" 
          showPageRange="0" 
          showOrdinals="0" 
          showScores="1" 
          showStats="0" 
          Alias="XSLTsearch" 
          runat="server">
        </umbraco:Macro>
      </form>
      </asp:Content>
  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 23, 2011 @ 10:37
    Douglas Robar
    0

    That wasn't what I wanted for formatting either, but at least now you can read it.

    cheers,
    doug. 

  • Stefan 117 posts 215 karma points
    Nov 23, 2011 @ 15:36
    Stefan
    0

    Sorry, I was not aware of that :/
    The form is now almost working properly!

    I'm only having one issue. The search string shows in the input text field after submitting a search from another form.
    Whenever I wan't to do another search from the "new" form (created on the search-results page),
    the querystring that is sent looks like this "/soege-resultater.aspx?search=my-search-string&search=Search".

    I found it being related to this piece of XSLT code:

                <input id="submit" class="fancy" type="submit" name="search" >
                  <xsl:attribute name="value">
                    <xsl:value-of select="$dictionaryButton-Search"/>
                  </xsl:attribute>

    The button has the value of "Search", and for some reason that is automatically submitted to the search.

    Any clues why?

    Best regards,
    Stefan.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 23, 2011 @ 15:50
    Douglas Robar
    0

    No problem, Stefan!

    When you submit the search form, XSLTsearch looks for the input field called 'search' to know what to search for. If you've got multiple fields called 'search' in the same form they will all get submitted and that will confuse XSLTsearch as you can imagine.

    The solution is to have only one search field called 'search'. Or at least only have one such field that has a value. 

    It looks like you added the name="search" and class="fancy" attributes to the submit button and that's the problem. Just call the button something other than "search" or simply don't give it a name.

    Here's the code from XSLTsearch 3.0.3 for reference:

    <input name="search" type="text" class="input">
                  <xsl:attribute name="value">
                    <xsl:value-of select="$unescapedSearch"/>
                  </xsl:attribute>
                </input>
                <xsl:text>&nbsp;</xsl:text>
                <input type="submit" class="submit">
                  <xsl:attribute name="value">
                    <xsl:value-of select="$dictionaryButton-Search"/>
                  </xsl:attribute>
                </input>

    cheers,
    doug. 

  • Stefan 117 posts 215 karma points
    Nov 23, 2011 @ 16:22
    Stefan
    0

    Thank you again :)
    Everythink works perfectly now!

    I really appreciate your work with XSLTsearch - it's really a must have package!

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 23, 2011 @ 16:28
    Douglas Robar
    0

    You're welcome, glad you're finding it helpful.

    cheers,
    doug. 

Please Sign in or register to post replies

Write your reply to:

Draft