More in this section

Forums / General Discussions / Hiding Content From Site Search / Crawlers

Hiding Content From Site Search / Crawlers

6 posts, 0 answered
  1. John
    John avatar
    61 posts
    Registered:
    08 Jun 2012
    10 May 2011
    Link to this post
    Hello,

    We would like to exclude certain parts of our pages from being rendered when requested by the search indexer or other crawlers.

    In v3.x, we were able to this:
    protected override void Render(HtmlTextWriter writer)
    {
        // Do not render this control for the index crawler
        // (we don't want the contents of this control to be indexed)
        if (!Telerik.CmsContext.IsCrawlerRequest)
        {
            base.Render(writer);
        }
    }
     which would prevent a control's contents from rendering for the crawlers. How can we accomplish the same in 4.x?

    Thank you!

    Regards,
    John G.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    12 May 2011
    Link to this post
    Hi John,

    You can use the code below.

    var page = GetPage(pageNode, provider, htmlWriter, out context);
    if( page.Items["IsInIndexMode"])
    {

    }

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. John
    John avatar
    61 posts
    Registered:
    08 Jun 2012
    12 May 2011
    Link to this post
    Hi Ivan,

    The example code you posted does not work in the context of the "Render" method of a control (i.e. the example code I posted). I am not familiar with the "GetPage" method. I checked the PageManager object, but did not see it there either.

    Could you provide some clarification on how to use the code you posted?

    Thank you!

    Regards,
    John
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 May 2011
    Link to this post
    Hi John,

    The code works just fine, since we the same index key in our code base. GetPage is a method that returns System.Web.UI.Page. So if you have access to the System.Web.UI.Page object you call .Items[key]

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Brett Whittington
    Brett Whittington avatar
    33 posts
    Registered:
    12 Jan 2012
    13 Feb 2012
    Link to this post
    I have been trying to do this same thing and I am not having any luck finding the GetPage method that is described as the answer to this problem.  Can anyone provide me with where this is located?  I am also trying to use this in a user control.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Feb 2012
    Link to this post
    Hello,

    You can use the standard ASP.NET Page and its Items property

    http://msdn.microsoft.com/en-us/library/system.web.ui.page.items.aspx

    Another option is to follow this blog post

    http://www.sitefinity.com/blogs/ivanpelovski/posts/12-02-06/hiding_page_content_from_the_search_engine_in_sitefinity_using_layout_widgets.aspx


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered