More in this section

Forums / Developing with Sitefinity / Sample Products Module & SiteMenu Bar

Sample Products Module & SiteMenu Bar

3 posts, 0 answered
  1. Greg
    Greg avatar
    82 posts
    Registered:
    08 Aug 2012
    31 Dec 2009
    Link to this post
    Hey everyone!

    I'm working on my first Sitefinity project and loving it so far! I've successfully implemented the Sample Products module which we will be customizing for our clients needs. I'm wondering if it is possible to dynamically add the categories/products to our SiteMenu navigation bar at the top of the page that we use for site navigation? For example, our current nav looks like this:

    Home
    Products
    Recipes
       - Breakfast
       - Lunch
       - Dinner
    About Us
       - History
       - Etc.
    Contact us

    I'd like something like this:

    Home
    Products
       - Rice
          > Organic Rice
          > Regular Rice
       - Chips
          > Sub Category of Chips
    Recipes
       - Breakfast
       - Lunch
       - Dinner
    About Us
       - History
       - Etc.
    Contact us

    I've tried taking a stab at this, however, my programming skills are lacking. Thanks for any suggestions or tips!

    - Greg
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    05 Jan 2010
    Link to this post
    Hello Greg Delorey,

    You have to bind the navigation control - RadMenu or RadTreeView to the list of your categories. Below is a sample code that gets all categories and subcategories for News provider.

    <telerik:RadMenu ID="RadMenu1" runat="server" Skin="Outlook" ></telerik:RadMenu>

    protected void Page_Load(object sender, EventArgs e)
    {     
        var manager = new NewsManager("News");
        IList allcategories = manager.Content.GetCategories();
        this.RadMenu1.DataTextField = "CategoryName";
        this.RadMenu1.DataFieldID = "ID";
        this.RadMenu1.DataValueField = "ID";
        this.RadMenu1.DataFieldParentID = "ParentCategoryID";
        this.RadMenu1.DataSource = allcategories;
        this.RadMenu1.DataBind();
    }

    You just need to use ProductsManager instead of NewsManager in the sample above.

    Greetings,
    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. Greg
    Greg avatar
    82 posts
    Registered:
    08 Aug 2012
    07 Jan 2010
    Link to this post
    Thanks, Ivan! I'll give this a shot and let you know how it works out.

    : Greg
Register for webinar
3 posts, 0 answered