Umbraco 8 - Calculate number of days past / between two dates
Mark Downie Blog
by
7M ago
  DateTime parsedDate = DateTime.Parse(item.Value<DateTime>("testimonailDate").ToString("dd MMMM yyyy")); var daysPast = (DateTime.Today - parsedDate).TotalDays;  @if(daysPast == 1)                                                 {                                                     <span >@daysPast  day ago</span> ..read more
Visit website
Umbraco 9 - Strip HTML and Truncate text output
Mark Downie Blog
by
7M ago
Umbraco 9 - Strip HTML and Truncate text/html output.  The code below can be used for truncating/shortening text and striping out HTML tags in Umbraco 9 to display shorter text useful for landing pages. Instructions:  Replace "bodyText" with the reference to the property you would like to truncate. Code: Example output ..read more
Visit website
Umbraco 9 - Left hand sub page navigation code snippet.
Mark Downie Blog
by
7M ago
Umbraco 9 - Left hand sub page navigation code C# RAZOR snippet.  The code below can be used for left hand navigation in Umbraco 9 to create left hand/sub page navigation.  Instructions:  Create a partial _leftHandNavigation  Reference the partial in your Umbraco template, like this: @Html.Partial("_leftHandNavigation") Code: Example output: https://www.buymeacoffee.com/markdevelopment/umbraco-side-bar-left-hand-navigation ..read more
Visit website
Umbraco 8 Convert Line Breaks for TextArea Example
Mark Downie Blog
by
7M ago
 Umbraco 8  Convert Line Breaks for TextArea Example @Html.ReplaceLineBreaksForHtml(@Model.Value("lineOne").ToString ..read more
Visit website
Umbraco 8 Pagination
Mark Downie Blog
by
7M ago
Umbraco 8 Pagination / Paging: @inherits Umbraco.Web.Mvc.UmbracoViewPage @{     Layout = "master.cshtml";         var pageSize = 8;     if(Model.HasValue("numberOfItemsPerPage")){     pageSize = Model.Value<int>("numberOfItemsPerPage");}         var page = 1; int.TryParse(Request.QueryString["page"], out page);     @* This line assumes you have a property called lastUpdated*@     var items = Model.Children().OrderByDescending(x => x.Value("lastUpda ..read more
Visit website
Umrbaco 8 Date Formatting
Mark Downie Blog
by
7M ago
Format a Date in Umbraco 8 @(Model.Value<DateTime>("publicationDate").ToString("dd MMMM yyyy")) or in a foreach loop: @(item.Value<DateTime>("publicationDate").ToString("dd MMMM yyyy ..read more
Visit website
Umbraco 8 OrderBy a collection by a Custom Field Such as a Date
Mark Downie Blog
by
7M ago
This is a snippet for Umbraco 8  to Order a collection by a Custom Field Such as a Date. @{     var selection = Umbraco.Content(Model.Id)     .ChildrenOfType("publication")     .Where(x => x.IsVisible())     .OrderBy( x => x.Value("publicationDate")); } @foreach (var item in selection.Take(1)) {      <h2><a href="@item.Url" title="@item.Name">@item.Name</a></h2> ..read more
Visit website
Umbraco 8 Umbraco Strip and Umbraco Truncate - usefull for landing pages
Mark Downie Blog
by
7M ago
Umbraco 8: <p>@Html.StripHtml(@Html.Truncate(@item.Value("bodyText").ToString(), 65))   (Thanks to A.S for the above)   Umbraco 7:    <p>@Umbraco.StripHtml(@Umbraco.Truncate(@Umbraco.Content(1067).bodyText, 300))</p> ..read more
Visit website
Umbraco 8 Metadata Snippet, keywords, meta title.
Mark Downie Blog
by
7M ago
Umbraco 8 Metadata Snippet, keywords, meta title, meta description: The following is a snippet that may help with generating metadata. I created this as a partial and added it to the Main Template. If the metadata fields are not filled in on the backend by the editor, they are generated from the Page Name and the Name of the Website (applicationName). ---- In the example the backend meta fields are called: "metaTitle"   (textstring) "metaDescription"   (textstring) "metaKeywords" (tags) ---- @inherits Umbraco.Web.Mvc.UmbracoViewPage @{     var applicatio ..read more
Visit website
Umbraco 7 Umbraco Strip and Umbraco Truncate - usefull for landing pages
Mark Downie Blog
by
7M ago
<p>@Umbraco.StripHtml(@Umbraco.Truncate(@Umbraco.Content(1067).bodyText, 300))</p> ..read more
Visit website

Follow Mark Downie Blog on FeedSpot

Continue with Google
Continue with Apple
OR