Copied to clipboard

Flag this post as spam?

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


  • Mirhat 11 posts 91 karma points
    Mar 17, 2018 @ 12:21
    Mirhat
    0

    Query one to many

    I have document type with content picker and I want to know how to find all content that is referencing particular content.

    For example Content1 and Content2 is referencing Content 3. How can I get Content1 and Content 2 if I know id of Content 3.

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Mar 17, 2018 @ 12:40
    Dave Woestenborghs
    0

    You could install my nexu package : https://our.umbraco.org/projects/backoffice-extensions/nexu/

    This stores all references as Umbraco relations.

    You could use the relations api to get the data you want : https://our.umbraco.org/documentation/Reference/Management/Services/RelationService

    Dave

  • Mirhat 11 posts 91 karma points
    Mar 17, 2018 @ 13:40
    Mirhat
    0

    Thank you Dave I will try it

  • Pawel Bres 39 posts 160 karma points c-trib
    Mar 17, 2018 @ 17:24
    Pawel Bres
    0

    You can also use Examine for that. Just create searchCriteria and set the search query like this:

    var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"]; var searchCriteria = searcher.CreateSearchCriteria(); searchCriteria.Field("yourContentPickerProperty", contentId); var searchResults = searcher.Search(searchCriteria);

  • Mirhat 11 posts 91 karma points
    Mar 17, 2018 @ 17:49
    Mirhat
    0

    I have new problem contentId is int but in database yourContentPickerProperty is stored as umb://document/0dec2b61774547b1b96956895d59f231

  • Mirhat 11 posts 91 karma points
    Mar 17, 2018 @ 20:21
    Mirhat
    0

    I have finished with something like this

    var searchCriteria = searcher.CreateSearchCriteria();
    var key = "umb://document/" + podkategorija.GetKey().ToString().Replace("-", "");
    searchCriteria.Field("kategorija", key);
    var searchResults = searcher.Search(searchCriteria);
    
  • 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