Copied to clipboard

Flag this post as spam?

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


  • Prachi Vyas 10 posts 110 karma points
    May 16, 2019 @ 09:19
    Prachi Vyas
    0

    Filter On Given card list

    Hello All,

    I want to know how would I apply filters in my card list If my data comes from query builder.

    enter image description here

    @{
    var Id = Request.RawUrl; //Gets value from url
    
    if (Request.RawUrl.Contains("?maker="))
    {
        var tempID = Id.Split('?').Last(); //splits unnecessary characters
        string[] data = tempID.Split('&');
    
        string maker = data[0].Split('=').Last();
        string body = data[1].Split('=').Last();
        string keyword = data[2].Split('=').Last();
    }
    
    var selection = Umbraco.Content(Guid.Parse("3758071d-10c8-4890-b680-64f43a7b4149"))
    .Children("vehicles")
    .Where(x => x.IsVisible())
    .OrderByDescending(x => x.Id);
    
    
    int pageSize = 6; // Number of News per page
    int page = 1; // The page we are viewing
    
    if (!int.TryParse(Request.QueryString["page"], out page))
    {
        page = 1;
    }
    var totalNodes = selection.Count();
    
    int totalPages = (int)Math.Ceiling((double)totalNodes / (double)pageSize);
    
    if (page > totalPages)
    {
        page = totalPages;
    }
    
    else if (page < 1)
    {
        page = 1;
    }
    

    }

  • Thomas 319 posts 606 karma points c-trib
    May 18, 2019 @ 02:01
    Thomas
    100

    Would it work by adding an extra where condition?

    var selection = Umbraco.Content(Guid.Parse("3758071d-10c8-4890-b680- 
    64f43a7b4149"))
    .Children("vehicles")
    .Where(x => x.IsVisible() && x.GetPropertyValue("XXXX") == **VALUE**)
    .OrderByDescending(x => x.Id);
    
  • Gilles 27 posts 109 karma points
    May 18, 2019 @ 06:41
    Gilles
    0

    I would look into using Examine for filtering your data. Especially if you have a lot of items in your DB. Examine (or rather Lucene) is the search engine which Umbraco uses to index all items. It is super fast.

Please Sign in or register to post replies

Write your reply to:

Draft