Design/Property question for doing quotes.
# help-with-umbraco
m
I run a gaming site and I want to have quotes from different characters for different games. Each game has it's own node under the home page. What I want to be able to do is display the quotes in 3 different ways in 4 different areas. The first would just list out the quotes for a character on that character 's page. Second is to pick a random quote for the game in the second the person is browsing to display on the navigation menu (i.e. if your in the game a aera you see a random game a quote if in be random game b quote) Third that on the home page a random quote from all available quotes. And Last is for game compilation (i.e. games a,b and c in a single package) displays a radom quote from a, b, or c. In my first design of my site I had the a "quotes" node under each section. And this worked for scenarios 1-3 but not for 4. Then I learned about the tree picker and was think for the compilation I could have a picker to chose the quote nodes to pull from. That should be good to address scenario 4. I was also thinking just have a master "quotes" node, under that a node for each game, then character. Then just used the node picker to assign the nodes to each section/character node. I would like yo get some thoughts from more experienced Umb devs on if either of these is better or maybe some other way? Thanks.
l
You can traverse the content hierarchy in several ways to achieve what you want. Have a look at this doc, and combine that with LINQ. https://docs.umbraco.com/umbraco-cms/reference/templating/mvc/querying
m
Thanks but I am good with the backend code. Just looking for advice on the front end design side.
l
What I suggested is for razor, not backoffice. Not sure what you define as front-end otherwise. 😇
m
Sorry, misunderstood your post. I do know how to traverse and what not just was hoping to get some layout/structure advice from more experienced cms people for this.
d
tl;dr: I would make one quotes folder with list view They way you intend to use these quotes, it would make the most sense to me to have one folder for all the quotes. If the quotes are unique for each game and character, then it might make sense to have subfolders per game and/or character. Subfolders do give the content editor more maintainance, so I would only recommend if it helps to keep a good overview. Instead, I would just use the list view on the quotes folder and for each quote have a field to assign one or more characters to it. Your code would work in 3 steps: 1. Find out which games you need quotes for 2. Find out which characters are part of those games 3. Find out which quotes match those characters
l
Can see I've been too quick on the trigger answering from my phone. The design might sooner or later be affected by performance concerns. But until that happens I think design should trump. Depending on whether characters should be able to share quotes or not, I'd move the quotes closer to the characters. If quotes are nothing but plain strings I'd even go with the "Multiple Text String" datatype on each character. To get quotes from several characters you could for instance go:
Model.Children<Game>().Where(x => selection.Contains(x.Key)).SelectMany(x => x.Characters.SelectMany(y => y.Quotes))
to get quotes for chars in game A, B and C. But again, this all depends on amount of data, complexity of quotes and relations to chars. 🙃 D_Inventors suggestion is way better for flexibility with those. A mid step for more complex quote types could be blocklists on the chars. I'd definitely look to keep them close if they're not to be shared.
5 Views