+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Remove page redirection for group pages

Remove page redirection for group pages

19 posts, 0 answered
  1. Oleg
    Oleg avatar
    7 posts
    Registered:
    02 Mar 2009
    27 Apr 2009
    Link to this post
    Hi. Could I avoid redirection to a first page in the group for a group pages.
    Actually, I want root items in the site menu to be not a links.
    Thanks, Oleg.
    PS. there is extra question, why first loading of home page takes up to 10 sec. Is there any way to decrease this time? (web site www.aerosan.ie)
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Apr 2009
    Link to this post
    Hello Oleg,

    To remove the redirect set HideUrlForGroupPages property of the RadMenu to false. As for the 10 seconds loading I load your home page for  3,5 secs without browser caching. To improve performance you can use page caching.

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Oleg
    Oleg avatar
    7 posts
    Registered:
    02 Mar 2009
    28 Apr 2009
    Link to this post
    Thank you for your help. Only one thing, this property should be 'true'.
    And if I use breadcrumb control is any chance to hide links for parent group pages as well. And also can I have Home page link to be displayed at the start of Breadcrumb control without making Home page as group page?

    Thanks once more.
    Oleg
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Apr 2009
    Link to this post
    Hi Oleg,

    Displaying the home page is quite difficult due to the reason that breadcrumb control uses SiteMap data source and inherits SiteMapPath. Here is an working sample that shows how to override control and remove the group pages. The idea is that we do not initialize the group pages.

    using Telerik.Cms; 
    using Telerik.Cms.Web; 
    using Telerik.Cms.Web.UI; 
     
    /// <summary> 
    /// Summary description for CustomBreadCrumb 
    /// </summary> 
    ///  
     
    namespace Telerik.Samples 
        public class CustomBreadCrumb : Breadcrumb 
        { 
            // here we do not initialize the item 
            protected override void InitializeItem(System.Web.UI.WebControls.SiteMapNodeItem item) 
            { 
                CmsSiteMapNode cmsNode = item.SiteMapNode as CmsSiteMapNode; 
                if (cmsNode != null && cmsNode.CmsPage.PageType == CmsPageType.Group) 
                    return
                base.InitializeItem(item); 
            } 
        } 


    The possible way is adding the following declaration in your master page or create a user control that you will add to your pages.

     <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="/" Text="HomePage" /> &raquo;    
    <sfweb:Breadcrumb ID="Breadcrumb1" runat="server" PathSeparator=" > " />  

    Another option is extending our CustomBreadCrumb control and add home url.

    Here is a sample:

    namespace Telerik.Samples 
        public class CustomBreadCrumb : Breadcrumb 
        { 
            public string HomePageUrl 
            { 
                getreturn this.homePage;} 
                setthis.homePage = value;} 
            } 
            private string homePage; 
     
     
            // here we do not initialize the item 
            protected override void InitializeItem(System.Web.UI.WebControls.SiteMapNodeItem item) 
            { 
                CmsSiteMapNode cmsNode = item.SiteMapNode as CmsSiteMapNode; 
                if (cmsNode != null
                { 
                    HyperLink link = new HyperLink(); 
                    link.Text = "HOME" + ">"
                    link.NavigateUrl =  HomePageUrl; 
                    Controls.Add(link); 
                } 
     
                   // return; 
                base.InitializeItem(item); 
            } 
        } 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    17 Jun 2009
    Link to this post
    Is there a "HideUrlForGroupPages" property for Site Tree View, because I can't find it.  I ask because I also want page groups to not be hyperlinks.

    Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jun 2009
    Link to this post
    Hi Orion,

    You can implement the following logic as below:

    ..... 
          ..... 
        public void RadTreeview1_NodeBound(object o, RadTreeNodeEventArgs e) 
        { 
            CmsSiteMapNode node = e.Node.DataItem as CmsSiteMapNode; 
            if (node != null
            { 
                e.Node.Attributes.Add("PageID", node.PageID.ToString()); 
     
                if (this.hideUrlForGroupPages) 
                { 
                    if (node.PageType == CmsPageType.Group) 
                    { 
                        e.Node.NavigateUrl = ""
                    } 
                } 
            } 
     
            CmsSiteMapNode node2 = SiteMap.CurrentNode as CmsSiteMapNode; 
            if (node2 != null && node2.ParentNode != null
            { 
                while (node2.ParentNode != SiteMap.RootNode) 
                { 
                    RadTreeNode item2 = this.RadTreeview1.FindNodeByUrl(this.ResolveUrl(node2.Url)); 
                    if (item2 != null
                        item2.Selected = true
                    node2 = node2.ParentNode as CmsSiteMapNode; 
                } 
                RadTreeNode item = this.RadTreeview1.FindNodeByUrl(this.ResolveUrl(node2.Url)); 
                if (item != null
                { 
                    // here you can set the style for the top-level item    
                    item.Selected = true
                } 
            }  
        } 
     
        [Browsable(true)] 
        [Category("Behavior")] 
        [DefaultValue(false)] 
        public bool HideUrlForGroupPages 
        { 
            get 
            { 
                return this.hideUrlForGroupPages; 
            } 
            set 
            { 
                this.hideUrlForGroupPages = value; 
            } 
        } 
     
        private bool hideUrlForGroupPages = false
       ..... 
     ..... 
     

    Thus when you click on RadTreeView node of type Group you will not be forwarded to a page.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    17 Jun 2009
    Link to this post
    Great!  I'll give it a try. 

    Can I enter this straight into "SiteTreeview.ascx.cs" without making any changes to the code?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jun 2009
    Link to this post
    Hello Orion,

    Just add the property under Properties region and you can copy-paste the ItemDataBound event. Let us know if there is anything else that we can do for you.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    18 Jun 2009
    Link to this post
    Hello again.  Thanks so much for all of the great help, but I'm getting an error message with the code above.

    I added the property under the properties section, and then replaced the code in the method section with the code you gave at the top of that sample.

    When I upload the new "SiteTreeview.ascx.cs" and refresh the page, my menu throws up the error "error CS0103: The name 'CmsPageType' does not exist in the current context."

    I'm not sure what to do next.

    Thanks,
    Orion
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jun 2009
    Link to this post
    Hello Orion,

    Use Telerik.Cms.CmsPageType or add "using Telerik.Cms" namaspace in the code behind.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    18 Jun 2009
    Link to this post
    Thanks so much!  That worked.  Now I just need to style them a little.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jun 2009
    Link to this post
    Hello Orion,

    For the styling you can take a look at Controlling Appearance.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  13. citytech team1
    citytech team1 avatar
    16 posts
    Registered:
    17 Sep 2009
    17 Sep 2009
    Link to this post
    Hi,
    I am very new to sitefinity. I could not find out the place where I can put my code for CustomBreadCrumb.
    Do I need to create new class library and create a dll file for it and then adding this reference to my user control ?
    Please help me. Thanks.
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Sep 2009
    Link to this post
    Hi citytech team1,

    You can add the control in App_Code folder and then register it inyour web.config file or compile it as separate dll. You can take a look at Controls Overview

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    30 Nov 2009
    Link to this post
    Is there a "HideUrlForGroupPages" property for SiteTabStrip?

    Thanks,
    Pik
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2009
    Link to this post
    Hi Pik Lee,

    There is no HideUrlForGroup page property for SiteTabStrip control. You can add the following logic to Page_Load event and this will prevent the redirection if a tab is group page.

    CmsManager manager = new CmsManager();
         foreach (ICmsPage page in manager.GetPages())
         {
             if (page.PageType == CmsPageType.Group)
             {
                 RadTab item = this.RadTabstrip1.FindTabByText(page.MenuName);
                 if (item != null)
                 {
                     item.NavigateUrl = "";
                 }
             }
         }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  17. Kris Marissens
    Kris Marissens avatar
    4 posts
    Registered:
    06 May 2010
    21 Oct 2010
    Link to this post
    Wouldn't it make more sense to render a span tag (for example <span class="rmNoLink"><span class="rmText">Page group text</span></span>) instead of an anchor with an empty fragment identifier when the HideUrlForGroupPages property is set to true? Since you wouldn't want the menu item to be a hyperlink. It could be called DisableUrlForGroupPages instead... Just a thought.
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Oct 2010
    Link to this post
    Hi Kris,

    When you bind the control ( RadTabStrip) to the SiteMapDatasource this sets automatically the NavigateUrl of the tab and this is why we have to remove it. If you are using the proper css skin selectors or java script to select some elements adding an empty span could introduce some issues.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Kris Marissens
    Kris Marissens avatar
    4 posts
    Registered:
    06 May 2010
    21 Oct 2010
    Link to this post
    I see...
    Another possibility could be to add that extra class="rmNoLink" to the already existing span with a class of "rmText" when the property is set to "true". This way: <span class="rmText rmNoLink">Text</span>
Register for webinar
19 posts, 0 answered