Copied to clipboard

Flag this post as spam?

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


  • Chris Barber 11 posts 109 karma points
    May 25, 2023 @ 10:57
    Chris Barber
    0

    Display a list of pdfs with a specific category

    What is the best way to query for a list of pdfs from the Media section with a specific property value (e.g. Category) and then display them in a View?

    Should I use a Controller and the MediaService as I cannot find any examples using this method, or in fact, any other method.

    Can someone please point me in the best direction?

    Thanks.

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    May 25, 2023 @ 12:16
    Marc Goodson
    100

    Hi Chris

    All the Media is available to query via the Examine Search Indexes

    https://docs.umbraco.com/umbraco-cms/reference/searching/examine/

    The MediaService would be operating directly on the database and would be slow, it's meant to be for CRUD admin tasks, rather than being used to render things on the front end of your site.

    If you go to the Settings section of your site and, click the Examine Management tab, you'll see a list of indexes for your site, if you click on the 'ExternalIndex' it will expand and you'll see a Search option, if you search for one of your PDFs, and then in the search results click on the green x Fields link... it will open up a panel showing all the information being held in the Examine Index for your Media Item.

    You'll see __IndexType is set to media

    When perform an Examine search you'll be able to use this to ljmit it to search Media only, similarly you can use umbracoExtension to restrict to PDFs, your picked 'category' mechanism should also be available here too...

    Hopefully the documentation link above gets you started with how to perform an Examine query, it's super fast!

    regards

    Marc

  • Chris Barber 11 posts 109 karma points
    May 25, 2023 @ 13:25
    Chris Barber
    0

    Thank you so much for your help. This is exactly what I was searching for. I have followed your instructions and the docs to create a SearchService which is perfect for my requirement.

Please Sign in or register to post replies

Write your reply to:

Draft