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

Forums / General Discussions / Page group in Breadcrumb

Page group in Breadcrumb

2 posts, 0 answered
  1. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    27 Aug 2010
    Link to this post
    Is that a way to disabled the link of Page group in the breadcrumb? I have pages set up like this

    PageA
        PageGroupA
                SubpageA
                SubpageB

    The breabcrumb looks like this:  PageA > PageGroupA > SubpageA. I would like PageGroupA show on the breakcrumb but not clickable.

    Thanks,
    ~Pik
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Aug 2010
    Link to this post
    Hello Pik Lee,

    You have to create a custom breadcrumb control and check if the node being created is a page group. Sample code can be found bellow:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Cms.Web;
    using Telerik;
    using System.ComponentModel;
     
    /// <summary>
    /// Summary description for CustomBreadcrumb
    /// </summary>
    public class CustomBreadcrumb : Breadcrumb, IEmptyControl
    {
        protected override void InitializeItem(System.Web.UI.WebControls.SiteMapNodeItem item)
        {
            ITemplate template1 = null;
            Style style1 = null;
            SiteMapNodeItemType type1 = item.ItemType;
            SiteMapNode node1 = item.SiteMapNode;
            switch (type1)
            {
                case SiteMapNodeItemType.Root:
                    if (this.ShowStartingNode)
                    {
                        template1 = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                        style1 = base.RootNodeStyle;
                        break;
                    }
                    this.skipNextSeparator = true;
                    return;
     
                case SiteMapNodeItemType.Parent:
                    template1 = this.NodeTemplate;
                    style1 = base.NodeStyle;
                    break;
     
                case SiteMapNodeItemType.Current:
                    template1 = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                    style1 = base.CurrentNodeStyle;
                    break;
     
                case SiteMapNodeItemType.PathSeparator:
                    if (!this.skipNextSeparator)
                    {
                        template1 = this.PathSeparatorTemplate;
                        style1 = base.PathSeparatorStyle;
                        break;
                    }
                    this.skipNextSeparator = false;
                    return;
            }
            if (template1 == null)
            {
                if (type1 == SiteMapNodeItemType.PathSeparator)
                {
                    Literal literal1 = new Literal();
                    literal1.Mode = LiteralMode.Encode;
                    literal1.Text = this.PathSeparator;
                    item.Controls.Add(literal1);
                    item.ApplyStyle(style1);
                }
                else if (!((type1 != SiteMapNodeItemType.Current) || this.RenderCurrentNodeAsLink))
                {
     
                    Literal literal2 = new Literal();
                    literal2.Mode = LiteralMode.Encode;
                    literal2.Text = node1.Title;
                    item.Controls.Add(literal2);
                    item.ApplyStyle(style1);
                }
                else
                {
                    CmsSiteMapNode cmsSiteMapNode = (CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode(node1.Url);
     
                    if (cmsSiteMapNode.Parent!=null && cmsSiteMapNode.CmsPage.Parent.PageType == Telerik.Cms.CmsPageType.Group)
                    {
                        Literal literal2 = new Literal();
                        literal2.Mode = LiteralMode.Encode;
                        literal2.Text = node1.Title;
                        item.Controls.Add(literal2);
                        item.ApplyStyle(style1);
                    }
                    else
                    {
                        HyperLink link1 = new HyperLink();
                        link1.EnableTheming = false;
                        link1.Enabled = this.Enabled;
                        link1.NavigateUrl = base.ResolveUrl(node1.Url);
                        link1.Text = HttpUtility.HtmlEncode(node1.Title);
                        if (this.ShowToolTips)
                        {
                            link1.ToolTip = node1.Description;
                        }
                        item.Controls.Add(link1);
                        link1.ApplyStyle(style1);
                    }
                }
            }
            else
            {
                template1.InstantiateIn(item);
                item.ApplyStyle(style1);
            }
     
        }
        [Browsable(false)]
        public bool IsEmpty
        {
            get
            {
                return this.DesignMode;
            }
        }
     
        public string SetEmptyControlDefaultMessage()
        {
            return "The control cannot be rendered in design mode.";
        }
     
        private bool skipNextSeparator;
    }


    Best wishes,
    Radoslav Georgiev
    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
2 posts, 0 answered