Sitefinity CMS

Implement Site TabStrip Hierarchy Depth Send comments on this topic.
How-to > Pages > Navigation > Implement Site TabStrip Hierarchy Depth

Glossary Item Box

SiteTabStrip implements the site hierarchy but has depth functionality only of level one. This is realized through the ShowFirstLevel property. The topic will provide details on how to set the SiteTabStrip and to which level should it be bound so that deeper hierarchy can be implemented.

 

Changing the Hierarchy Depth of SiteTabStrip 

Follow the described steps to implement hierarchy depth:

 

1. Add an integer property to determine the depth of the binding:

Add Property Copy Code
private int _hierarchyDepth = -1;  

[Category("Behavior")]  
public int HierarchyDepth  
{  
 get
 {  
   
return this._hierarchyDepth;  
 }  
 set
 {  
   
this._hierarchyDepth = value;  
 }  
}  

 

2. Modify the FillTabStrip function:

Modify FillTabStrip() Copy Code
private void FillTabStrip(SiteMapNode pNode, TabCollection pTabs, int levelDepth)  
{  
 
int levelPosition = -1;  
 
foreach (CmsSiteMapNode node in pNode.ChildNodes)  
 {  
   levelPosition++;  

   Tab tab =
new Tab(node.Title);  
   tab.NavigateUrl = node.Url;  
   pTabs.Add(tab);  
   
if (node == SiteMap.CurrentNode)  
   {  
     tab.Selected = true;  
     tab.Owner.SelectedIndex = levelPosition;  
     
if (levelDepth > this._hierarchyDepth)  
       tab.Visible = false;  
   }  

   
this.FillTabStrip(node, tab.Tabs, levelDepth + 1);  

   
if (tab.SelectedIndex >= 0)  
     tab.Owner.SelectedIndex = levelPosition;  
 }  
}  

 

3. Add another argument with 0 value to the calling code:

Add Argument Copy Code
FillTabStrip(SiteMap.RootNode, this.RadTabstrip1.Tabs, 0);

 

You could download the whole sample code from HERE.

 

Understanding SiteTabStrip Control

The partial class UserControls_SiteMapNavigationControls_SitemapTabstrip represents a wrapper for RadTabStrip and SitemapDataSource. It derives from System.Web.UI.UserControl. The control has the functionality of RadTabStrip. However, it is specifically configured for representing SiteMap data. It exposes the contained RadPanelbar as a property, whose own properties can be edited from the visual property editor of Sitefinity. 

 

ShowMembers

Public Properties

 

Name Description
bool ShowOnlyFirstLevel Gets or sets a value indicating whether the RadTabStrip should show only the first level of nodes in the SiteMap.
bool PerTabScrolling

Gets or sets a value indicating whether the TabStrip should scroll directly to the next tab. (Exposed from contained RadTabStrip.) Value should be true if the TabStrip should scroll to the next (or previous) tab; otherwise, it is false. The default value is false. By default tabs are scrolled smoothly. If you want the TabStrip to scroll directly to the next (or previous) tab, set this property to true. This property is applicable when the ScrollChildren property is set to true; otherwise, it is ignored.

bool ReorderTabRows  Gets or sets a value indicating whether the row of the selected tab should move to the bottom. (Exposed from contained RadTabStrip.) The value should be true if the row containing the selected tab should be moved to the bottom; otherwise false. The default value is false. Use the ReorderTabRows property to mimic the behavior of the Windows TabStrip control.
RadTabStripOrientation Orientation Gets or sets a value indicating the orientation of child tabs within the RadTabStrip control. (Exposed from contained RadTabStrip.) The value is one of the  RadTabStripOrientation values. The default one is HorizontalTopToBottom.
TabstripAlign Align Gets or sets the alignment of the tabs in the RadTabStrip control. (Exposed from contained RadTabStrip.) The value is one of the TabStripAlign enumeration values. The default one is Left.
string CssClass Gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. (Exposed from contained RadTabStrip.) It is inherited from System.Web.UI.WebControls.WebControl.
RadTabStrip TabStrip Represents a reference to the wrapped TabStrip control. Could be used to access properties which are not directly available in the user control.
int StartingNodeOffset Gets or sets a positive or negative integer offset from the starting node which determines the root hierarchy that is exposed by the data source control. (Exposed from contained SitemapDataSource.) (See more on StartingNodeOffset after the Members table)
bool StartFromCurrentNode Gets or sets a value indicating whether the site map node tree is retrieved using the node that represents the current page. (Exposed from contained SitemapDataSource.) The value is true if the node tree is retrieved relative to the current page; otherwise, it is false. The default one is false. The StartFromCurrentNode property is evaluated during calls to the GetView and the GetHierarchicalView methods to help determine which site map node to use as a starting point to build the node tree. The StartFromCurrentNode and StartingNodeUrl properties are mutually exclusive — if you set the StartingNodeUrl property, make sure that the StartFromCurrentNode property is false.
bool ShowStartingNode  Gets or sets a value indicating whether the starting node is retrieved and displayed. (Exposed from contained SitemapDataSource.) The value is true  if the starting node is displayed; otherwise, it is false. The default one is false. The ShowStartingNode property is evaluated during calls to the GetView and GetHierarchicalView methods, when the node tree returned by these methods is populated.
string Skin Gets or sets the skin used by RadTabStrip. (Exposed from contained RadTabStrip.) The value is a string specifying the skin. The default value is an empty string (""). If the default value is used, no skin is applied.
string SkinsPath Gets or sets the relative path of the folder containing the skins. (Exposed from contained RadTabStrip.)  A string specifying the relative path to the folder which contains RadTabStrip skins. The default value is "~/RadControls/TabStrip/Skins". If the skin folder is located in the project root and is named "Skins", the SkinsPath property should be set to: "~/Skins". Then, subfolders for individual skins could be created such as: Skins/Gold, Skins/Default and so on.

 

 

More on StartingNodeOffset

The default value is 0, which indicates that the root hierarchy exposed by the SiteMapDataSource is the same as the starting node. If the StartingNodeOffset property is set to a value other than 0, it affects the starting node and with it the site map data hierarchy that is exposed by the SiteMapDataSource control. The negative or positive integer value of the StartingNodeOffset identifies the number of levels up or down the site map hierarchy from the starting node. This is identified by the StartFromCurrentNode and StartingNodeUrl properties to offset the starting node of the subtree that is exposed by data source control.

 

If the identified starting node is the node that represents the currently requested page, the StartingNodeOffset is ignored. If the StartingNodeOffset property is set to a negative number - n, the starting node of the subtree that is exposed by the data source control is the ancestor node n hierarchical levels above the identified starting node. If the value n is greater than the number of ancestor levels in the hierarchical tree, the starting node of the subtree is the root node of the site map hierarchy.

 

RadTabstrip ships with a set of predefined skins which are ready to use. They are located in the folder RadControls/TabStrip/Skins.