CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: search

Add Search Verticals by code

search-verticals-001

Adding own search verticals is a common task in the Search Configuration in SharePoint. Here I want to share a code sample for achieving this programmatically. I hope, this model can be added to SPMeta2.

First of all, Search Verticals are dedicated Search Results Pages and links to them. How to add them manually is described on technet:

There is no API in CSOM for that. Luckily, Mikael Svenson found how to get the Search Navigation and contributed to PnP by writing an Extension: web.LoadSearchNavigation.

Here is my sample code for adding new Search Verticals programmatically:

NavigationNode searchNav = context.Web.Navigation.GetNodeById(1040);
NavigationNodeCollection nodeCollection = searchNav.Children;
NavigationNodeCreationInformation everything = new NavigationNodeCreationInformation
{
    Title = "Everyting",
    Url = "/search/Pages/results.aspx",
};
NavigationNodeCreationInformation myresults = new NavigationNodeCreationInformation
{
    Title = "My Results",
    Url = "/search/Pages/myresults.aspx",
};
nodeCollection.Add(everything);
nodeCollection.Add(myresults);
context.ExecuteQuery();
Advertisements

Resetting SharePoint Search Configuration Cache

Now it is the second time it happens that the search cannot return any results. This hickup is rare but it happens. To solve it I had to follow these steps:

  1. Stop the Timer Service
  2. Clear the configuration cache
    1. Find in \ProgramData\Microsoft\SharePoint\Config the folder where the file cache.ini exists
    2. Delete every file from this folder EXCEPT cache.ini
    3. Open cache.ini, delete the content and put ’1′ (without the quotes) in it and save the file
  3. Restart the Timer Service
  4. Index reset
  5. Full crawl

Source: ITIDea. The linked blog post saved my afternoon today. Thank you, Anita Boerboom.

Create your own search box

It is very simple. Create a new module: SearchArea. Delete Sample.txt and Elements.xml. Create a new file: SearchArea.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control
      Id="ContosoSearchAreaBox"
      Sequence="15"
      ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" 
      ControlAssembly="Microsoft.Office.Server.Search, Version=14.0.0.0, 
			Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="GoImageUrl">/_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageUrlRTL">/_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageActiveUrl">/_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageActiveUrlRTL">/_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="DropDownMode">HideDD_useDefaultScope</Property>
    <Property Name="FrameType">None</Property>
    <Property Name="UseSiteDefaults">false</Property>
  </Control>
</Elements>

Next add your searcharea module to a site scoped feature.

In the masterpage locate this:

<SharePoint:DelegateControl runat="server" 
       ControlId="SmallSearchInputBox" Version="4" />

and replace with your brand new search area:

<SharePoint:DelegateControl runat="server" 
       ControlId="ContosoSearchInputBox" Version="4" />

Now you have full control over the appearence and behavior of the search button. Create your own search button, or google it, style the input with css and add javascript if needed.

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

| Blockchain | Serverless Architecture | Microservices Architecture | DevOps | AWS Lambda | Teraform |

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis