Orchardcore: Dynamically created reusable parts not accessible by name

Created on 4 Sep 2019  路  6Comments  路  Source: OrchardCMS/OrchardCore

I was trying to inject a property in a Reusable Part shape but I was not able to access it using the Shape.Named("") method.

Example:

  • Create a Part called MyReusablePart from the admin UI.
  • Attach the part to a MyContentType ContentType twice : "RP1", "RP2"

    • Try to access the RP2 shape by using Model.Content.Named("RP2") does not work.

bug

Most helpful comment

i think we need to use a differentiator, i will take a look and maybe do a PR soon.
right now i'm seeing a football match while installing a new version of visual studio ;)

All 6 comments

When adding a reusable part template called MyReusablePart.cshtml, the template gets rendered for SummaryAdmin view.

@jptissot can you share you driver code? re the SummaryAdmin view?

Re the first question. Shape.Named("") is looking for the name of the shape from the Items list. It's name is recorded in the ShapeMetadata.Name property inside the items list. So you can debug it to find what the name is that you're need

I did not create a driver. simply created a Reusable Part from the admin.

@deanmarcussen The name of the shape is the actual shape name "MyReusablePart" and not the name assigned when attaching to the ContentItem "RP1"

Ah, I understand, will see if I can repro

i think we need to use a differentiator, i will take a look and maybe do a PR soon.
right now i'm seeing a football match while installing a new version of visual studio ;)

Was this page helpful?
0 / 5 - 0 ratings