Copied to clipboard

Flag this post as spam?

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


  • Jesper Dalsgaard 3 posts 74 karma points
    Feb 15, 2017 @ 09:51
    Jesper Dalsgaard
    0

    Render all options from Checkbox list

    Hi,

    I'm very new to Umbraco and working at my very first project. I ran into an issue that i hope that someone can help me solve. It's probably nothing, if you're a little more experienced.

    I'm using a Checkbox list to add "categories" to cases. These are used for filtering with JS in the frontend.

    Now i need to render all the options from the Checkbox list, and not just the ones selected.

    Here is what i got so far:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var itemsString = CurrentPage.casesMedarbjedere.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        var itemsCollection = Umbraco.Content(itemsString);
    
        var casesCollection = CurrentPage.Children.Where("Visible");
    }
    <div class="container-fluid filter-container" xmlns:data-cat="http://www.w3.org/1999/xhtml">
        @if (CurrentPage.DocumentTypeAlias == "sagsarkiv")
        {
            <div class="holder">
                <div class="col-md-12 udvalgte-cases">
                    <div class="container-fluid filter-container">
                        <div class="filters">
                            <ul id="filters" class="clearfix">
                                <li class="cases-title">Cases:</li>
                                <li class="filter active" data-filter="all">Alle.</li>
                                <li class="filter" data-filter=".Web">Web.</li>
                                <li class="filter" data-filter=".Kampagner">Kampagner.</li>
                                <li class="filter" data-filter=".Film">Film.</li>
                                <li class="filter" data-filter=".Design">Design</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="" id="portfoliolist">
                @{
                    foreach (var item in casesCollection)
                    {
                        var pickedCategories = item.kategori.ToString().Split(new string[ ] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        var punktum = ".";
                        var space = " ";
                        // Cases
                        if (item.HasValue("thumbnailBillede"))
                        {
                            var imageList = item.GetPropertyValue("thumbnailBillede");
                            var image = Umbraco.Media(imageList);
                            <div onmouseover="overlayOn(this)" onmouseout="overlayOff()" class="col-xs-12 col-sm-6 col-md-3 portfolio case1 @foreach (var categories in pickedCategories){@categories@space}" data-id="@item.Id" data-cat="@foreach (var categories in pickedCategories){@punktum@categories@space}">
                                <div class="case-overlay"></div>
                                <div class="port-text">
                                    <span class="case-header">@item.Name</span><BR>@item.tagline
                                </div>
                                <img src="@image.GetCropUrl("thumbnail")" id="case-img" alt="@item.Name">
                            </div>
                        }
                }
                }
            </div>
    

    I need to replace the <li> elements with content from the Checkbox list.

    Thx

  • Jesper Dalsgaard 3 posts 74 karma points
    Feb 15, 2017 @ 10:09
    Jesper Dalsgaard
    0

    The Checkboxlist has the alias "kategori". :)

  • Kenneth Jakobsen 67 posts 203 karma points hq
    Feb 15, 2017 @ 12:57
    Kenneth Jakobsen
    1

    It is possible, but the info is NOT cached which means you will be querying the database directly (which is very slow) so I really recommend another solution.

  • Jesper Dalsgaard 3 posts 74 karma points
    Feb 15, 2017 @ 14:28
    Jesper Dalsgaard
    1

    @Kenneth Jakobsen, thx for your quick reply. I will reconsider then. :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies