Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. @model TextOverImage.Models.ImageWithText
  2. @{
  3.  
  4. // Use this code to render this partial in your template. Replace "banner" with whatever your property name is
  5. // Make sure to include @using TextOverImage.Models at the top of your template
  6. //@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
  7. //{
  8. // @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
  9. //}
  10.  
  11. // You could use banner.Media.GetCropUrl(width,height) here instead if you want to set it!
  12. var imageUrl = Model.Media != null ? Model.Media.Url : string.Empty;
  13.  
  14. // Only render the style tag if the image url exists
  15. var style = !string.IsNullOrEmpty(imageUrl) ? MvcHtmlString.Create(" style=\"background: url(" + imageUrl + ") no-repeat center center; background-size: cover;\"") : MvcHtmlString.Empty;
  16. }
  17. <div class="banner banner--@Model.Height"@style>
  18. <div class="banner--inner banner--@Model.Position">
  19. <h1>@Model.Headline</h1>
  20. <h2>@Model.Subheadline</h2>
  21. @if (Model.Link != null)
  22. {
  23. <a href="@Model.Link.Url" target="@Model.Link.Target" class="button">@Model.Link.Name</a>
  24. }
  25. </div>
  26. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement