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

Forums / Developing with Sitefinity / SiteMenu Customization (Adding Image)

SiteMenu Customization (Adding Image)

6 posts, 0 answered
  1. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    10 Sep 2009
    Link to this post
    if (currentNode != null && currentNode.ParentNode != null)  
          {  
        while (currentNode.ParentNode != SiteMap.RootNode)  
            {  
               RadMenuItem item2 = this.RadMenu1.FindItemByUrl(this.ResolveUrl(currentNode.Url));  
                if (item2 != null)  
                    item2.CssClass = this.selectedItemCssClass;  
                    currentNodecurrentNode = currentNode.ParentNode as CmsSiteMapNode;  
                }  
                RadMenuItem item = this.RadMenu1.FindItemByUrl(this.ResolveUrl(currentNode.Url));  
                if (item != null)  
                {  
            if (currentNode.PageType == CmsPageType.Group)  
                    {  
                        if (item.Attributes["PageID"].Equals(currentNode.PageID.ToString()))  
                        {  
                            item.CssClass = this.selectedItemCssClass;  
                }  
                    }  
            else  
            {  
                // here you can set the style for the top-level item     
                item.CssClass = this.selectedItemCssClass;  
            }  
     
            if (e.Item.Level == 0)  
            {  
                e.Item.ImageUrl = "~/Images/arrowdown.gif";       
                          
            }    
          } 

     My Above code is not working as expected, I added ImageURL in order to add images in front of Root Items of Site Menu but Image is not showing with all of the root items
     Items, I don't have any idea why it is not showing for some of the root items and showing for some other items.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Sep 2009
    Link to this post
    Hi vivek garg,

    You can give a try to the code below:

       public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
     
          CmsSiteMapNode currentNode = SiteMap.CurrentNode as CmsSiteMapNode; 
            if (currentNode != null && e.Item.Level == 0) 
            { 
                e.Item.ImageUrl = "~/Files/menu.jpg"
                e.Item.Text = ""
            } 
        } 

    It is possible not to see the image if you have created any custom RadMenuItems after the binding.

    Sincerely yours,
    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.
  3. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    11 Sep 2009
    Link to this post
    Thanks Ivan, It work great the only thing, it is showing on the left side, instead I want to show it on right side.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Sep 2009
    Link to this post
    Hi vivek garg,

    You can use css to change the position of the image. You can take a look at Controlling Appearance.
    Sample code:

    .RadMenu .rmLeftImage { 
    floatrightright !important; 
    padding-right5px !important; 


    Kind regards,
    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.
  5. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    11 Sep 2009
    Link to this post
    How should I refer this stylesheet for image part, can you please point. Thanks.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Sep 2009
    Link to this post
    Hi vivek garg,

    Please take a look at the following topic - CSS Skin File Selectors. Since you are going to use the same image for all items you can create a custom skin and set it as a background image for the root items.

    .RadMenu_jjjj .rmRootGroup, 
    .RadMenu_jjjj .rmLink, 
    .RadMenu_jjjj .rmText, 
     
       background-imageurl('Menu/rmImage.png'); 


    Regards,
    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.
Register for webinar
6 posts, 0 answered