Taxonomy pages: showing all articles *or* articles written by one author
j
Request for advice on how to go about this: Say you have a blog. How do you have one page either show all articles or those filtered by a specific field/value (i.e. only those by a specific author, or a specific tag)? Honestly feel this is ultra basic but, realistically, I'm tired and have a POC deadline on Friday so figured I'd just ask/check that what I roughly think is correct is correct. TIA!
d
My go-to method would be examine. Examine is Umbraco's indexer that indexes all Umbraco pages. You can make a simple query in examine to find all documents that share similarity with your current page. Now examine has a little bit of a learning curve, so if you intend to take this direction and you're not familiar with it, you should keep that in mind
This part of the docs should tell you more: https://docs.umbraco.com/umbraco-cms/reference/searching/examine
j
I keep thinking about this - is there not a way to do something like a LINQ query like "Given a specific [User], get a list of all child [Article] pages of this page with [User] as author"? While Examine is obvs awesome I think it's overkill for what I'm looking for right now, I think it's more of a Razor pages/ASP.NET Core thing that I'm looking for/overthinking. (but thank you for that direction!)
d
You'd have to find something that they have in common. If it's the author, you should simply be able to do something like this:
Copy code
var currentAuthor = CurrentPage.Value<string>("author")
CurrentPage.Children().Where(c => string.Equals(c.Value<string>("author"), currentAuthor))

CurrentPage.Children<IMyAuthorComposition>().Where(c => c.Author == CurrentPage.Author);
If you need to go deeper, just use Descendants instead of Children
j
Will look into, thank you!
@D_Inventor OK so apparently this is definitely when I should be using Examine - just got through the POC so have a little more breathing space, so will now look into it! TY for the direction!
d
Happy to help 😊
8 Views