Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
This is my first time using content grids and I have been stuck on this a while. I am using Umbraco cloud.
I wish to display only the first 50 characters of an article and after 50 characters and ellipsis appears.
var selection = Umbraco.Content(Guid.Parse("01284c80-30c0-4891-b349-802237f90443"))
.Where(x => x.IsVisible());
@foreach (var item in selection)
var typedMediaPickerSingle = item.Value<IPublishedContent>("caseStudyLogo");
if (typedMediaPickerSingle != null)
<img src="@typedMediaPickerSingle.Url" />
<div class="case"> @Html.GetGridHtml(item, "caseStudyContent", "CSUSKGrid")</div>
<div class="casefooter"><img src="/_assets/css/images/caseimage.png"></div>
This displays all the text. I have tried a few versions of @Umbraco.Truncate but keep getting errors. My latest is
<div class="case"> @Umbraco.Truncate(@Html.GetGridHtml(item, "caseStudyContent", "CSUSKGrid"),50)</div>
Has anyone any ideas. I am still an Umbraco newbie.
GetGridHtml gets the entire grid you defined on your page and renders it.
Truncating that doesn't really make sense as it's a html structure.
There are a few ways to implement that, but it also depend on how you use your grid system.
The easiest way would be to use somekind of jQuery Ellipsis Plugin on your case div.
Another way would be to find your text content from the grid and then truncate it.
Can't you use Umbraco.StripHtml in combination with Umbraco.Truncate ?
Thanks Sebastion for pointing me in the right direction.
For Umbraco 8 you need
@Html.StripHtml(@Html.Truncate(@Html.GetGridHtml(item, "caseStudyContent", "CSUSKGrid"), 300, true))
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted