https://discord.umbraco.com logo
#help-with-umbraco
Attempting: Return "Lorem ipsum" content for all Block list items without hardcoding it.
# help-with-umbraco
c

chancer

10/17/2023, 8:15 AM
Hey all, A little bit of a feature experiment im trying to do on an Umbraco 12 site is to essentially "generate" a kitchensink page with one of each of my various blocks on it. At this point in time I have 30 various element types that are allowed in a block list editor and around 10 in a block grid editor. Im looking at having a kitchensink page in which I can call upon the same partials that are used to render the various blocks but effectively sub in any .Value("") calls with some predefined static content (Thinking Lorem Ipsum for text fields. https://via.placeholder.com/ links for images, a default youtube video for embeds e.t.c.) I was wondering how others may go around tackling this. The main thing im trying to tackle is not having duplicates of all my partials to avoid needing to maintain a second view. Initial ideas I had were: - Creating a way of injecting fallback values based on URL route - Providing a custom View Model to the partials with default content set in the Model itself - overriding the .Value call to look upon a different data source based on some sort of option (be it a parameter in a generic render controller, a simple boolean flag on the template e.t.c) Any ideas / guidance is much appreciated ❤️
m

mistyn8

10/17/2023, 10:30 AM
Copy code
csharp
@(Model.Value<string>(PublishedValueFallback, "title", fallback: Fallback.ToDefaultValue, defaultValue: {loremipsum}));
https://docs.umbraco.com/umbraco-cms/reference/querying/ipublishedcontent/properties#fallback-to-default-value
c

chancer

10/17/2023, 12:12 PM
Hey Mike, Cheers for the docs link - Yeah this is very close to what I need to achieve. Just need to make it Document type dependant.