دنبال کننده ها

۱۳۹۶ مهر ۱۰, دوشنبه

orchardcms - How to reliably extend MenuItem ContentTypes?

[ad_1]



I was trying to add additional settings to Menu Items by attaching a custom Part.



// Migrations

ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", type => type
.WithPart("CustomMenuSettingsPart")
);

ContentDefinitionManager.AlterTypeDefinition("MenuItem", type => type
.WithPart("CustomMenuSettingsPart")
);

...


This works as expected. My custom editor shows up when I edit any menu item and my settings are persisted. The problem is accessing the Part before the menu is rendered.



I was hoping to cast the Item shapes in Menu.cshtml to my CustomMenuSettingsPart through their Content property. However, in the case of ContentMenuItems, the Content property refers to the content in the ContentPicker, not the MenuItem itself so I can't cast it.



Is there a way to reach the MenuItem content item from the Item Shape or a way to alter the Item shape construction without touching the source?




[ad_2]

لینک منبع