Multiple templates for search widget
I added a template for my site wide search on my master page. I mapped the control through Administration > Settings > Advanced > Controls > ViewMap.
LayoutTemplatePath: "~/WidgetTemplates/SearchBox.ascx" (relative path to your template)"
I want to add a separate search for my forums but I need it to be styled differently. How do I accomplish this? When I drop a search control on the forums page it is styled the same as the site wide search. Is there some place else I can register these layouts so they only apply to a specific search control?
Anyone have any ideas?
Thnak you for using our services.
Please note that when you map a template globally from Controls->ViewMap this template will be applied globally to all instances of the controls matching the specified HostType, throughout Sitefinity.
If you want to apply different templates per widget you can modify directly the widget template the control, or use an external template per control. For more information about the above approach, please check this section from our documentation, I hope you find it useful.
the Telerik team
Yes, I understand that setting the template from Controls->ViewMap applies the change globally. I've read through the documentation and the only other place I have found that allows me to set a search template is under Settings->Toolboxes->PageControls->Sections->Search->Tools->Search. But when I set the Layout Template to the path of my user control and save, the changes are not reflected on the frontend.
What else can I do?
I have exact same requirements.
I already created a custom template for the searchbox and set the ViewMap, same as @Jeff describes in the post. That template is for the searchbox displayed in the header and set to use a generic index.
I also need a few more searchboxes to be placed in different regions of the page, and each would be set to use different indexes. So I'd prefer to use different placeholder text, different styles for those additional searchboxes.
Yet, I haven't found any way to map multiple templates and use them for different purposes.
Any update on this topic?
There is a bug logged already for this and it would be fixed for the next internal build.
The bug is that the SearchBox control doesn't have Advanced mode. In the advanced mode you will be able to specify the template of the search box.
Does this solution suit your needs?
Once there would be an Advanced button allowing us to define a template path for each search-box, it'll be much easier for sure.
Right now, I embed my custom searchboxes in widget templates (i.e. blog list template) and it works. But this is not the ideal solution, just a workaround.
If someone out there need this workaround until this bug is fixed on a stable release...
Simply add following in your widget template:
And don't forget to include:
Thank you for sharing this workaround.
The advanced section for the search box will be available in the next internal build.