Skip to content

Instantly share code, notes, and snippets.

@RobotOptimist
Created February 12, 2020 14:19
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 RobotOptimist/ecd23497c2c12b4b84f5a8d9865adb1e to your computer and use it in GitHub Desktop.
Save RobotOptimist/ecd23497c2c12b4b84f5a8d9865adb1e to your computer and use it in GitHub Desktop.
Sitefinity code snippits and explanations

get an image from a built in content type

For news and events content items you can't use the built in GetRelatedItems or anything like you would with a Dynamic Content Item. Instead you have to do this to get a related item, this is for an Image (in cshtml):

@model Telerik.Sitefinity.Frontend.Mvc.Models.ContentDetailsViewModel

@using Telerik.Sitefinity.Libraries.Model

@{
  var image = (Image)Model.Item.Fields.YourImageFieldName.DataItem
}

<img src="image.ResolveMediaUrl" alt="image.AlternativeText">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment