Copied to clipboard

Flag this post as spam?

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


  • Dimitris Lampsakis 4 posts 74 karma points
    Feb 10, 2016 @ 20:24
    Dimitris Lampsakis
    0

    Filter blog posts

    Hello. 1st of all I’m using version 7.3.3 with fanoe starter kit. I am trying to find the best and not that hard way to filter the blog post by some "options" that i have Created. I have created new properties on the "blog spot" document type. one is "Country" and the second one is "Project type" i managed to get the existing values on both of them and place then on

                    @{ 
                        var posts = CurrentPage.Children;
                        var usedcountries = new List<string>();
                        var usedProjectTypes = new List<string>();
                    }
                    <div class="col-sm-3">
    
                            @foreach (var post in posts)
                            {
                                if (!usedcountries.Contains(post.countries))
                                {
                                    usedcountries.Add(post.countries);
                                };
    
                            }
                            @{usedcountries.Sort();}
    
                        <select id="theCountry">
                            <option value="none">Any Country</option>
                            @foreach (var c in usedcountries)
                            {
                                <option value="@c">@c</option>
                            }
                        </select>
    
                    </div>
                    <div class="col-sm-6">
    
                            @foreach (var post in posts)
                            {
                                if (!usedProjectTypes.Contains(post.projectType))
                                {
                                    usedProjectTypes.Add(post.projectType);
                                };
                            }
                            @{usedProjectTypes.Sort();}
    
                        <select id="theType">
                            <option value="none">Any Project Type</option>
                            @foreach (var p in usedProjectTypes)
                            {
                                <option value="@p">@p</option>
                            }
                        </select>
    
                    </div>
                        <div class="col-sm-3">
                            <button onclick="myReloadFunction()">Search</button>
    
    
    
    <script>
                                function myReloadFunction() {
    
    
                                    var e = document.getElementById("theCountry");
                                    var _theSelectedCountry = e.options[e.selectedIndex].value;
    
                                    var e = document.getElementById("theType");
                                    var _theSelectedType = e.options[e.selectedIndex].value;
    
                                }
                            </script>
    
    
                        </div>
    
                </div>
    

    FYI - i still don't know much about XSLT.. i know good Linq and maybe an API solution might fit.. but I might be wrong.,. Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft