How to hide an element on a PageBuilder page from showing up in search results

  • Updated

This KB article shows how to hide elements from the search results when you search on pagelayout content.  For example, you may want to exclude menu content results on a page.

There are 2 samples below. The first has been tested in more recent versions.

//The following code sample is added to the Page_load event
if(!string.IsNullOrEmpty(Request.QueryString["pbwebrequest"]))
{
//hide control here.
}

The following code sample is added to the Page_load event of a master page to hide the FlexMenu in your original template, if the builtin user is logged in. (For Web requests made during PageBuilder Indexing, Ektron uses the builtin user.)

ContentAPI api = new ContentAPI();
if (api.RequestInformationRef.UserId == EkConstants.BuiltIn)
{
  uxNavigationGlobal.Visible = false;
  return;
}

The last important step is to republish the pagelayout in the Workarea, which starts a search crawl and puts the fix in place for your search results.