You can make your own <form> in your master template and set the action="" to your search page. Just be sure the search field has a name/id of "search" and XSLTsearch will pick up what you typed in. You can use either a GET or POST method in your form and XSLTsearch will just work.
If you want to stop XSLTsearch from displaying its own search form on the search/results page you only need to set the XSLTsearch macro property to "NONE". All the macro properties are fully detailed in the PDF docs.
This is exactly what I do on my blog, for instance... search field in master template and disable the built-in search field in the XSLTsearch macro itself. You can see an example at http://blog.percipientstudios.com
Of course, if you have a form tag on your master template that surrounds the search field you may have some difficulty because that will cause a form tag to appear inside a form tag, which isn't allowed. That's a problem with asp.net generally, not XSLTsearch.
Anyway, let me know what you're trying to accomplish in more detail and I'm sure we can get it sorted out for you.
Carlo and I are trying to achieve the same thing, which is what you're doing on your blog - turning off the search boxes in XSLTsearch's macro and creating an input in the master template which then redirects to the XSLTsearch page.
I'm doing it with a .NET usercontrol and a rewired master template, because my master templates have <form> tags in them and need to have them there for every page, so to get this to work with XSLTsearch I have to create a new master template and remove a batch of usercontrols.
That's right, if your design forces you to have the <form runat=server> tag around the search textbox then you'll need to have a small user control.
I think Warren had that problem with his CWS2 package and includes a simple usercontrol to resolve the issue. Take a look at his solution, as I recall it is quite generic and would work for anyone.
It's also quite common to have your searchbar near the top of your page, so you could put the searchform code before you start your runat server form, i.e.
search bar on the master page
I installed this package and it created a search node with the search bar on it..
Is there a way I can use this package so I can use it to place the search bar as a macro on my master page?
Hi Carlo,
I'm making a custom usercontrol to do this as there is no way of using the XSLTsearch macro itself just to show a single search bar on another page.
Best,
Benjamin
Benjamin,
Is this something you'll share?
I'm sure the Umbraco beginners (me) would love this
Hi Carlo,
I'll ask Doug if he'd consider adding it to the XSLTsearch package, otherwise I'll make the code available on my blog (once it's up and running).
Best,
Benjamin
I'm not quite sure what you mean, Carlo.
You can make your own <form> in your master template and set the action="" to your search page. Just be sure the search field has a name/id of "search" and XSLTsearch will pick up what you typed in. You can use either a GET or POST method in your form and XSLTsearch will just work.
If you want to stop XSLTsearch from displaying its own search form on the search/results page you only need to set the XSLTsearch macro property to "NONE". All the macro properties are fully detailed in the PDF docs.
This is exactly what I do on my blog, for instance... search field in master template and disable the built-in search field in the XSLTsearch macro itself. You can see an example at http://blog.percipientstudios.com
Of course, if you have a form tag on your master template that surrounds the search field you may have some difficulty because that will cause a form tag to appear inside a form tag, which isn't allowed. That's a problem with asp.net generally, not XSLTsearch.
Anyway, let me know what you're trying to accomplish in more detail and I'm sure we can get it sorted out for you.
cheers,
doug.
Hey Doug,
Carlo and I are trying to achieve the same thing, which is what you're doing on your blog - turning off the search boxes in XSLTsearch's macro and creating an input in the master template which then redirects to the XSLTsearch page.
I'm doing it with a .NET usercontrol and a rewired master template, because my master templates have <form> tags in them and need to have them there for every page, so to get this to work with XSLTsearch I have to create a new master template and remove a batch of usercontrols.
Best,
Benjamin
That's right, if your design forces you to have the <form runat=server> tag around the search textbox then you'll need to have a small user control.
I think Warren had that problem with his CWS2 package and includes a simple usercontrol to resolve the issue. Take a look at his solution, as I recall it is quite generic and would work for anyone.
cheers,
doug.
Thanks Doug, sounds sweet, I'll check it out :-)
Doug what you're trying to describe is what I'm trying to accomplish.
I posted this in my masterpage and now I have a working search box! Thank you
<form action="/search.aspx" method="get">
<div class="xsltsearch">
<input name="search" type="text" class="input" value="" />
<input type="submit" value="Search" class="submit" />
</div>
</form>
Excellent! Glad you got it working, and thanks for posting the solution.
cheers,
doug.
Hi Douglas/Carlo
I am trying to do the same thing that you have done by posting:
onto my Master Template.
The page correctly directs to Search.aspx but search itself seems to not be working.
However if I choose:
I get the proper search results but they just dump onto the page (which doesn't work for me).
Any help or direction would be much appreciated!
Owen
Can you copy and paste your full html?
Make sure you don't have nested form tags.
<form class="right" id="searchDesign" action="/search.aspx" method="get"><input name="search" type="text" class="text" value="" /> <input type="submit" value="Search" class="button" /><!--<input name="search" text="" class="text" /> <input type="submit" value="Search" class="button" />--></form>
<div class="left" id="logo">
<a href="/"><img src="/css/images/crestlogo.png" alt="Homepage"/></a>
</div>
<div class="left navigation" id="main-nav">
<umbraco:Macro Alias="RunwayDropdownNavigation" runat="server" />
<div class="clearer"> </div>
</div>
<div class="clearer"> </div>
</div>
</div>
<form id="RunwayMasterForm" runat="server">
<asp:ContentPlaceHolder ID="RunwayMasterContentPlaceHolder" runat="server"></asp:ContentPlaceHolder>
</form>
This is a snippet from my masterpage. The search is on its own node -- hidden. The form tags aren't nested.
Hope this helps.
Hi Carlo,
Thanks for your help, I ended up having a problem with my permissions on my Usercontrols folder...very frustrating!
Thanks again,
Owen
I was able to get around the nested form issue using javascript.
<input type="button" id="searchbutton" class="submit" onclick="parent.location='/search.aspx?search=' + window.document.getElementById('searchbox').value" value="" />
It's also quite common to have your searchbar near the top of your page, so you could put the searchform code before you start your runat server form, i.e.
<formclass="right"id="searchDesign"action="/search.aspx"method="get"><inputname="search"type="text"class="text"value=""/><inputtype="submit"value="Search"class="button"/></form>
<form runat="server">
Everything else
</form>
How would you customize the searchbar and button?
Hi Plindgren
By customizing are you then thinking in terms of layout or in terms of functionality?
If you're thinking about how to customize the desgin of the form elements then you can use the id's of each elemen to add some custom css.
But please ellaborate a bit more on what it is you intend to do so we can provide some better answers for you :)
/Jan
is working on a reply...