Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naepalm/05bf4c97730e6d0b5d135846dd830808 to your computer and use it in GitHub Desktop.
Save naepalm/05bf4c97730e6d0b5d135846dd830808 to your computer and use it in GitHub Desktop.
An example for how a DocType Grid Editor partial view should look with the DTGE: Reusable Content Extension
@inherits UmbracoTemplatePage
@{
// Set a variable to use the default content if no linked content has been selected
var content = Model.Content;
// Check to see if there's a linked page value
if(Model.Content.HasProperty("dtgeLinkedId") && Model.Content.HasValue("dtgeLinkedId"))
{
// Run the linked page value through Umbraco.TypedContent() to get the IPublishedContent page
var dtgePage = Umbraco.TypedContent(Model.Content.GetPropertyValue("dtgeLinkedId"));
// The value shouldn't ever be null, but weird things happen, so let's just make sure
if(dtgePage != null)
{
// Set the content to use the linked page instead of the default DTGE values
content = dtgePage;
}
}
}
@* Now you can do anything you want with any version of the content in your view! *@
@content.GetPropertyValue("propertyExample");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment