Cloning BlockList from one Node to another
# help-with-umbraco
b
I have a DocType/Node with a BlockList that is acting as a template. When a new page is created I want to use that Node and copy a BlockList property on it to a property on the new Node/Page. This is what I have so far. But it doesn't BlockItems or change UIDs: https://pastebin.com/waA4NCCz
d
Block List and Grid items are copy pasteable from one page to another if that's what you are after?
b
Thanks @Dean Leigh not exactly. I want to take away the manual steps of copy pasting so it reduces the chances of an error. SO far I;ve managed to: 1 - When a user creates a certain node with a certain ContentType then I'll fetch a BlockList from a "Template" 2 - The BlockList is then copied and shown to the user on the "new" page pre-saved 3 - There are a couple of issues with the code I shared in the pastebin - There are child BlockList content items that don't get copied - The UIDs don't get replaced which will lead to problems when the user saves the content Thanks for the response, I really appreciate any help with it/
d
Does each new node use the same Block List template or does the user have a few to choose from?
b
@Dean Leigh same one
m
Sounds like you just need to create content template
It allows you to create pre filled templates your users can then delete when building a page. https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/content-templates
d
Sorry @Brendan I went to bed 🙂 What @Matt Wise said would be my next suggestion. However, we have found that users find it very easy to use Block Grid for Layout and where you can restrict what is allowed in each area. At which point you can offer users a single content block if you wish to restrict it.
b
When content is changed it needs to update all existing Nodes. Is that possible?
s
Not out of the box, if that is what you want you are probably better having one node with the blocks, and then a reference (content picker) on the other nodes to the node with the blocks.
b
That's a good suggestion. But the requirements are more complex. The users need to be able to update the blovks in the child blocklist but the other of the blocks in the parent can't be changed It's pretty complex and although all the suggestions so far are excellent they don't meet the requirements. Only way I can see it working is to copy the blocklist on create. On save of master blocklist template I need to cycle through the related blocks lists and update the content if it hasn't changed. First step is get the create working on new node. Has anyone got a copy block working before? Thanks again for the help .
Does anyone know where the core node functionality lives in the main Source? It might have something.
d
So what you are describing is being referred to by Umbraco as reusable content, in fact I think they may even have another name for it now. But the point being is it is being worked on for the new back office. As you mention it can get complex as requirements are often that you have one piece of content which is used throughout the site but you can then detach it from the original content to create a new instance and then of course it can go even deeper where you can then reuse the customized instances of the reusable content. This was something I first came across many years ago using Flash and a few modern ux design tools also give you reusable components that can be detached from their roots component and can even create variations that are reusable. There are workarounds for example we store links to external websites in the next turn or link library where the content gets written within that node and then reused in blocks where the content gets called into that block. This means that if a website changes its URL we can change it in one place in our external link library and it will be chained throughout the whole website. We have used this concept for many years and editors find it easy to learn and understand and to use. This can be very easily implemented in both block list and block grid.
b
@Dean Leigh that's really interesting and would be really helpful. I guess re-usable content is going to be a future thing and I can't utilise it now? Have you any example of cloning BlockList?
d
We tend to use Block Grid more than Block List but an example would be the categories for the libraries in https://designinglibraries.org.uk/libraries/ We have created a Data Library and within that a Library Type folder which can only contain Library Types. Each Library Type has a single text field but it could easily contain an RTE / Image etc. This can now be called into any Block via an Element Type i.e. Block content. So you could easily create a library of content this way. https://cdn.discordapp.com/attachments/1229475671382954114/1229770921170960458/msedge_LQ6N16TbMW.mp4?ex=6630e46b&is=661e6f6b&hm=a5ac742980373104ee7bae70d0d6cdca57dbb6fdbedcb6719c0135cc12ff08b5&
b
@Dean Leigh that could work. I'm going to try and flesh out the requirements a bit more as they seem up in the air at the moment. There's a lot of food for thought in this thread and I really appreciate everyones input and help!
d
Happy to help anytime
7 Views