More in this section

Forums / Developing with Sitefinity / Extending SiteMapDataSource with a page description

Extending SiteMapDataSource with a page description

8 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    29 Sep 2008
    Link to this post
    Hi,

    I'd like to use the RadPanelbar or RadTabStrip to render a list of links to child pages on a "landing page".  The Basically I want to add the page description from each child page to the SiteMapDataSource, and somehow expose that in the output HTML so that I can write a vertical list of links like:

    Page 1 Title
    Page 1 Description

    Page 2 Title
    Page 2 Description
      
    Page 3 Title
    Page 3 Description
      
    Page 4 Title
    Page 4 Description
        
    Is this possible?  If so, how would I do this?

    Thanks in advance!
    Mike
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    30 Sep 2008
    Link to this post
    Hi Mike,

    Please refer  to the following forum thread that provides a solution for the required functionality: http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bkhaag.aspx

    Do let us know if this helps.

    All the best,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    30 Sep 2008
    Link to this post
    Thanks Pepi,

    I guess that will work, but it means (at least in the case of the tabstrip) that the description text is hyperlinked.  Also, since the tabstrip doesn't seem to be databound, I was able to do something like you suggest in the code where the tabs are added to the collection.  However the result isn't quite how I'd like it to appear.

    What I would really like to do is control the HTML output of things like the tabstrip control.  I'm sure there's a way to do it with rendering templates, but I couldn't find any documentation that covered this, and my attempts didn't work out the way I expected (that is, I got my template output along with the controls normal output).  I suppose this is fundamental ASP.NET stuff though, so I'll look through the Microsoft documentation as well.

    Thanks,
    Mike
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    03 Oct 2008
    Link to this post
    Hello Mike,

    I would recommend you use SiteTabstrip user control (~/Sitefinity/UserControls/Navigation/SiteTabstrip.ascx) which is provided by Sitefinity and modify it as follows:

    .ascx
    <div> 
    <radTS:RadTabStrip ID="RadTabstrip1" runat="server" Orientation="VerticalLeftToRight" Skin="VerticalSimple" EnableViewState="false"></radTS:RadTabStrip> 
    </div> 

    .ascx.cs
    protected void Page_Load(object sender, EventArgs e) 
        { 
            if (this.ShowOnlyFirstLevel) 
            { 
                foreach (SiteMapNode node1 in SiteMap.RootNode.ChildNodes) 
                { 
                    CmsSiteMapNode cmsNode = node1 as CmsSiteMapNode; 
     
                    Tab tab = new Tab(); 
                    tab.Text = node1.Title + "<br/>" + cmsNode.CmsPage.Description; 
                    tab.NavigateUrl = node1.Url; 
                    this.RadTabstrip1.Tabs.Add(tab); 
                } 
             ... 

    For details please refer to the online help of RadTabStrip for ASP.NET.

    Do let us know if this helps.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    03 Oct 2008
    Link to this post
    Thanks Pepi,

    That's essentially the same solution as the link you provided at the beginning of this thread.  It does work, but as I said, it makes the entire text part of the hyperlink.  But, I guess in this case it will work, as I can style the text so it doesn't *look* like a hyperlink.

    I take it there's no way to override the default HTML output of tabstrip or the other controls using <ItemTemplate> in the ascx?  So that I could produce something like:

    <li>
        <a href="{url}">Page Title</a>
        <span>Page Description</span>
    </li>



    Thanks again for the great support!
    Mike
  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    07 Oct 2008
    Link to this post
    Hello Mike,

    Classic RadTabStrip does not support templates. But you could use RadTabStrip for ASP.NET AJAX instead of classic RadTabStip to define a template that is automatically applied to all items. Here is a simple example:

    .ascx
    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %> 
    <div> 
        <telerik:RadTabStrip ID="RadTabstrip1" runat="server" EnableViewState="false"
            <TabTemplate> 
                <li> 
                    <onclick="document.location='<%# Eval("Url") %>'" target="_self"><%# Eval("Title") %></a
                    <span><%# Eval("Description") %></span
                </li> 
            </TabTemplate> 
        </telerik:RadTabStrip> 
    </div> 

    .ascx.cs
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (this.ShowOnlyFirstLevel) 
            { 
                this.RadTabstrip1.DataSource = this.GetDataSource(); 
                this.RadTabstrip1.DataTextField = "Title"
                this.RadTabstrip1.DataNavigateUrlField = "Url"
                this.RadTabstrip1.DataBind(); 
     
                CmsSiteMapNode node2 = SiteMap.CurrentNode as CmsSiteMapNode; 
                if (node2 != null && node2.ParentNode != null
                { 
                    while (node2.ParentNode != SiteMap.RootNode) 
                    { 
                        node2 = node2.ParentNode as CmsSiteMapNode; 
                    } 
                    RadTab item = this.RadTabstrip1.FindTabByUrl(this.ResolveUrl(node2.Url)); 
                    if (item != null
                    { 
                        // here you can set the style for the top-level item    
                        item.Selected = true
                    } 
                } 
                else if (this.RadTabstrip1.Tabs.Count > 0) 
                { 
                    this.RadTabstrip1.Tabs[0].Selected = true
                } 
            } 
            else 
            { 
                SiteMapNode root = this.GetStartingNode(); 
                if(root.ParentNode != null
                    FillTabStrip(root.ParentNode, this.RadTabstrip1.Tabs, 0); 
                else 
                    FillTabStrip(root, this.RadTabstrip1.Tabs, 0); 
            } 
        } 
     
        private DataTable GetDataSource() 
        { 
            DataTable table = new DataTable(); 
            table.Columns.Add(new DataColumn("Title")); 
            table.Columns.Add(new DataColumn("Url")); 
            table.Columns.Add(new DataColumn("Description")); 
     
            foreach (SiteMapNode node1 in SiteMap.RootNode.ChildNodes) 
            { 
                CmsSiteMapNode cmsNode = node1 as CmsSiteMapNode; 
                DataRow row = table.NewRow(); 
                row["Title"] = cmsNode.Title; 
                row["Url"] = this.ResolveUrl(cmsNode.Url); 
                row["Description"] = cmsNode.CmsPage.Description; 
                table.Rows.Add(row); 
            } 
     
            return table; 
        } 

    For your convenience I have attached the full example (it represents a modified version of the SiteTabstrip control).

    Do let us know how it goes.

    Sincerely yours,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    07 Oct 2008
    Link to this post
    Thanks Pepi,

    As usual, you folks are awesome.  I've been putting off upgrading to the radcontrols for ASP.NET AJAX because I didn't want to complicate my current project, but I can see now that it's worth it.  It's fantastic to be able to override the HTML. 

    From another post, it seems like I should install the Q1 2008 SP2 version, not the Q2 2008, at least until Sitefinity V3.5 comes out. 

    Thanks again,
    Mike
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Oct 2008
    Link to this post
    Hi Mike,

    Thank you for your nice words :)
    You are right about the RadControls versions. There are some issues with the newest RadControls and Sitefinity 3.2SP2 hotfix, which are already fixed in 3.5 Release.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
8 posts, 0 answered