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 100 karma points
    1 week ago
    Prachi Vyas
    0

    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 Hansen 72 posts 253 karma points
    7 days ago
    Thomas Hansen
    0

    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 16 posts 88 karma points
    7 days ago
    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