Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Amigo 243 posts 568 karma points
    Oct 25, 2014 @ 07:37
    Amigo
    0

    show hide entire category

    is there a way to show hde categories?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 25, 2014 @ 13:01
    Dennis Aaen
    100

    Hi Amigo,

    If you see on the the default category definition in uCommerce you have a property called Display on website. So if this is checked it should display the category on the website. And if it´s unchecked then it should not display the category on the website.

    What you need is to update the razor file that print out your categories, and add a where clause. My example is based on the uCommerce demo razor store. So I have made the changes into the file called LeftNavigation.cshtml in the demo razor store.

    @using UCommerce.Api
    @using UCommerce.EntitiesV2
    @using UCommerce.Extensions
    @using UCommerce.Runtime
    @helper RenderNavigation(ICollection<Category> categories)
        {
        if (categories.Any())
        {
            <ul class="nav nav-list">
                @foreach (var category in categories.Where(x => x.DisplayOnSite).OrderBy(x => x.SortOrder))    
                {
                    var currentCategory = SiteContext.Current.CatalogContext.CurrentCategory;
                    var css = "";
                    if (currentCategory != null && currentCategory.CategoryId == category.CategoryId)
                    {
                        css = " class=\"on\"";
                    }
                    <li @Html.Raw(css)>
                        <a href="@CatalogLibrary.GetNiceUrlForCategory(category)">@category.DisplayName()</a>
                        @RenderNavigation(category.Categories)
                    </li>
                }
            </ul>
        }
    }


    @RenderNavigation(CatalogLibrary.GetRootCategories())

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft