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
Hi there
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")) .Children() .Where(x => x.IsVisible()); } @foreach (var item in selection) { var typedMediaPickerSingle = item.Value<IPublishedContent>("caseStudyLogo"); if (typedMediaPickerSingle != null) { <div class="main-case"> <div class="caselogo"> <img src="@typedMediaPickerSingle.Url" /> </div> <div class="casebody"> <div class="truncate-ellipsis"> <h5><a href="@item.Url">@item.Name</a></h5></div> <div class="case"> @Html.GetGridHtml(item, "caseStudyContent", "CSUSKGrid")</div> </div> </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.
Hi Mark.
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 ?
Umbraco.StripHtml
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:
Upload image
Image will be uploaded when post is submitted
How do you truncate text in content grid
Hi there
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.
This displays all the text. I have tried a few versions of @Umbraco.Truncate but keep getting errors. My latest is
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.
Hi Mark.
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 withUmbraco.Truncate
?Thanks Sebastion for pointing me in the right direction.
For Umbraco 8 you need
is working on a reply...