Creating Blockgrid/Blocklist programmatically
t
Hi I've been looking into the ContentService for Umbraco 13 and there's an example of creating a simple page programmatically but I can't find any examples of creating a Blockgrid or Blocklist programmatically. I have a document type which contains a Blockgrid/list which has a simple rich text editor to test against (and an image if this makes any difference). How could I save data to this Rich text box when it contains a Blockgrid/list? Thank you
t
I see what you mean @Jemayn is there an easy way to populate the Json for the Blockgrid I have (I can convert it into a C# class)? I'm not using the settings just one property for testing purposes
j
Last I checked the classes they use for block data in the core weren't public so you had to set up your own. Everytime I've had the need for something like this I've ended up doing it in other ways as it became problematic
c
Hi, I've done it in my package called QuickBlocks. Here is the service I wrote for creating a BlockList programmatically https://github.com/prjseal/QuickBlocks/blob/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks/Services/BlockCreationService.cs#L358
314 Views