I am relatively new to Umbraco (and coming back to .NET after many, many years away), but have ended up on a project using it (v8). I am finding it fascinating at the moment. The site I am building has a lot of different layouts / templates (each page seems to be different), so I am building up each page using partials and compositions where possible, and nested content in other areas.
I have tried the grid with Macros and I didn't get on with it for my circumstances.
The problem I have is that some of the pages have 2, or more, instances of the same partial, seperated by another partial. e.g. layout could be something like:
Hero
Banner with some text
Block of content
Banner with some text (number 2)
Block of content (number 2)
I can add them to the document type, but when I try to render them using Html.Partial I get the same content in each (the first instance content).
Does anyone have an advice on how I can overcome this and use multiple instances of the same partial on the page? Can I pass an ID to the partial so it identifies the correct version? I have searched the docs and couldn't find any indication on it as yet.
Multiple Instances of Composition / Partial
Hi,
I am relatively new to Umbraco (and coming back to .NET after many, many years away), but have ended up on a project using it (v8). I am finding it fascinating at the moment. The site I am building has a lot of different layouts / templates (each page seems to be different), so I am building up each page using partials and compositions where possible, and nested content in other areas.
I have tried the grid with Macros and I didn't get on with it for my circumstances.
The problem I have is that some of the pages have 2, or more, instances of the same partial, seperated by another partial. e.g. layout could be something like:
I can add them to the document type, but when I try to render them using Html.Partial I get the same content in each (the first instance content).
Does anyone have an advice on how I can overcome this and use multiple instances of the same partial on the page? Can I pass an ID to the partial so it identifies the correct version? I have searched the docs and couldn't find any indication on it as yet.
Thanks in advance,
John
Hi John,
You can simply pass the Model (or specific data) to a partial that you are rendering, for example:
If you're using Umbraco8.7+ I'd recommend using the BlockList Editor, so you can easily add new components to a page. I think it's exactly what you are looking for: https://our.umbraco.com/Documentation/Fundamentals/Backoffice/property-editors/built-in-property-editors/Block-List-Editor/
Thanks for the response. I will take a look at the block list editor, sounds like the sort of thing I need.
Update - This is exactly what I needed. Thanks to Ambert for the help.
is working on a reply...