Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
This post will describe how to create a layout widget that hides its content from the search engine in Sitefinity. This type of layout widget is useful if you want to hide a content block from the indexing or you don't want to write the same control logic for every widget you develop. Writing this layout widget is pretty simple. All that has to be done is to extend the built-in control LayoutControl and reuse the layout templates.
So let's start by adding a new class to your SitefinityWebApp project. Give it a proper name (in this sample it is called NonSearchableLayout) and make it to extend the LayoutControl.
NonSearchableLayout : Telerik.Sitefinity.Web.UI.LayoutControl
Next we'll override two of the methods of System.Web.UI.Control class:
.GetIndexRenderMode() == Telerik.Sitefinity.Web.UI.IndexRenderModes.Normal;
The GetIndexRenderMode() method is an extension method. It says whether the page is rendered by the search engine or it is rendered normally. Setting the Visible property of the control to False makes the control to skip the work it usually does when it is visible. It even skips calling the Render method but for any case we'll override the Render method too.
.GetIndexRenderMode() == Telerik.Sitefinity.Web.UI.IndexRenderModes.Normal)
// Just in case. Should not be called in normal cases if the control has its property Visible set to False
So this is it. Build the SitefinityWebApp project and the layout widget is ready to be registered in Sitefinity. The documentation page for registering custom layout widgets is here, but here is what to be done:
Now you can edit one of your pages and give a try to the new layout widget.
I want to add a note about the usage of this layout. You may ask do you need such layout widget for the other template types ("Two columns with 50% width each.", etc.) The good thing is that you can use the other layouts with this new one in various combinations. For example you don't want the content inside one of your layouts to be indexed. Simply drop a non searchable layout and move the other layout inside. Or you may want the content inside the left part of one of your layouts not to be indexed. In this case drop the new layout in the left part of the existing layout and move its content to the new layout. You can even position a layout widget among other widgets (Content Blocks, News Widget, etc) so you can exclude a certain widget from the search and not exclude its neighbor widgets.
The layout widgets of Sitefinity are a really powerful instrument that can be used for purposes not only related to styling. In this case we used them to change the behavior of other widgets in different scenarios.
If you have a question or want to make a suggestion please leave a comment.
View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.