Search Box Template

Posted by Community Admin on 03-Aug-2018 09:50

Search Box Template

All Replies

Posted by Community Admin on 14-Jan-2011 00:00

Hi Team,

I just upgraded my sitefinity 4 project to RC 2 this week and i was able to add the search box to the master page using the following code:

<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Services.Search.Web.UI.Public" Assembly="Telerik.Sitefinity" %>
 
 
<sitefinity:SearchBox ID="searchBox" runat="server" IndexCatalogue="MyIndex" ResultsUrl="~/Search"></sitefinity:SearchBox>

However, i checked the widgets templates and i am not able to modify the template for the search box. I need to remove or style the fieldset and change the layout.

Is it possible in this release or should i just try a workaround and override the css classes for the control with custom css?

Thanks,

G

Posted by Community Admin on 14-Jan-2011 00:00

Hi George ,

You can map the template by using LayoutTemplatePath property. Below is the declaration of the template

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sitefinity" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
 
<fieldset id="main" class="sfsearchBox" runat="server">
    <asp:TextBox ID="searchTextBox" runat="server" CssClass="sfsearchTxt" />
    <asp:Button  id="searchButton" runat="server" Text="<%$Resources:SearchResources, Search %>" OnClientClick="return false;" CssClass="sfsearchSubmit" />
</fieldset>



All the best,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Jan-2011 00:00

Hi Ivan,

Thank you for your response, I have mapped the external template as you suggested and changed the layout. However, the other issue is that the control is not working

I have set the properties as follows

<sitefinity:SearchBox ID="searchBox" runat="server" IndexCatalogue="MyIndex" ResultsUrl="~/Search" LayoutTemplatePath="~/Custom/ControlTemplates/SearchBox.ascx"></sitefinity:SearchBox>

I have created the myIndex catalog in the back-end and also the Search page holding a SearchResults control and the search is not being submitted through the control. I have removed the OnClientClick event and also tried to remove the LayoutTemplatePath but still not working.

I have tried to add the control to a test page from the toolbox and it worked but the one i added to the master page didn't and there is not Javascript error.

Any suggestions?

Appreciate it in advance.

Posted by Community Admin on 17-Jan-2011 00:00

Hi Ivan,

Do you have any input on the above.

Appreciate it.

G

Posted by Community Admin on 19-Jan-2011 00:00

Hello George ,


Can you send us a quick mock-up of the the search widget that you want to create? I think it would be easier for us to help you and to propose the best solution.


Best wishes,
Jordan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Jan-2011 00:00

Hi Jordan,

I have attached an image of the layout that i am trying to achieve for the search box. I managed to add the search box to the master page as a control (i have added the code in this thread). 

The only problem is that once i embed the search box in the master page and not through sitefinity the button do not trigger a postback.

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sitefinity" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
  
 <div class="searchbox">
    <asp:TextBox ID="searchTextBox" runat="server" CssClass="searchText" ClientIDMode="Predictable" />
    <asp:Button  ID="searchButton" runat="server" Text="Search"  CssClass="searchSubmit" OnClientClick="return false;" />
</div>
 
<script type="text/javascript">
 
    $(function ()
        var searchBox = $("[id$='_searchTextBox']");
 
        addWaterMark(searchBox, 'search');
    );
 
</script>


Thanks,

G

Posted by Community Admin on 24-Jan-2011 00:00

After investigating the generated code, I found that the index catalog in the javascript code is not being set ... How will i be able to set the index catalog? and what is SearchIndexPipeId property?

                Sys.Application.add_load(loadHandler);
                )();Sys.Application.add_init(function()
$create(Telerik.Sitefinity.Services.Search.Web.UI.Public.SearchBox, "indexCatalogue":"","resultsUrl":"/Search","searchButton":$get("searchBox_ctl00_ctl00_searchButton"),"searchTextBox":$get("searchBox_ctl00_ctl00_searchTextBox"),"wordsMode":0, null, null, $get("searchBox"));


Thanks,

G

Posted by Community Admin on 26-Jan-2011 00:00

Hello George ,

You can use the built-in SearchBox control.  You have to set SearchIndexPipeId property. It gets or sets the ID of the search index pipe from which the search catalogue is resolved. The easiest way to get the pipe Id is to make a query to [sf_publishing_pipe_settings] table of the database.

Regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 27-Jan-2011 00:00

Hi Ivan,

I tried your solution and it finally worked. 

Appreciate it 

Best,

G

Posted by Community Admin on 17-Aug-2011 00:00

Hi George ,

Can u Please share ur Search Code Step by Step ... i have Created my Site in Sitefinity 4.0 ... i want to implement Site Search ...

Please wil be highly Appreciated ...

Thanks & Regards
Anu.

Posted by Community Admin on 31-Aug-2011 00:00

Hi Ivan,

Can u Please share ur Search Code Step by Step ... i have Created my Site in Sitefinity 4.0 ... i want to implement Site Search ...



Thanks & Regards,
Pravat Sharma

Posted by Community Admin on 03-Sep-2011 00:00

hey guys,

Sorry for the late reply. Check out this blog post, i explained it there

http://gsaadeh.com/blog/11-05-31/Adding_Searchbox_directly_to_your_Template_in_SF_4.aspx

Cheers

This thread is closed