Skip to content

Instantly share code, notes, and snippets.

@jonathanread
jonathanread / ContentLocationHelper.cs
Created December 1, 2021 18:21
Get related news articles by categories.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.ContentLocations;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Services;
namespace CLane.Helpers
{
@jonathanread
jonathanread / Detail.DetailPage(BlogPost).cshtml
Created December 1, 2021 17:48
News default view template with view count incrementor implemented on Line #7 of both cshtml files.
@model Telerik.Sitefinity.Frontend.Mvc.Models.ContentDetailsViewModel
@using Telerik.Sitefinity;
@using Telerik.Sitefinity.Frontend.Mvc.Helpers;
@using Telerik.Sitefinity.Web.DataResolving;
@{SitefinityWebApp.Extensions.ViewsCountHelper.IncrementNewsViewCount(Model.Item.Fields.Id);}
<div class="@Model.CssClass" @Html.InlineEditingAttributes(Model.ProviderName, Model.ContentType.FullName, (Guid)Model.Item.Fields.Id)>
<h3>
@jonathanread
jonathanread / CustomChoicesCalculatedField.cs
Created May 14, 2019 15:20
This Calculated field is intended to return the string values of a choices field on a content item. Follow instructions here to add the property to your web service. You will need to replace 'Features' with your Property name. https://www.progress.com/documentation/sitefinity-cms/for-developers-custom-calculated-properties
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.DynamicModules.Model;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Web.Services.Extensibility;
@jonathanread
jonathanread / List.DocumentsWithSubs.cshtml
Created August 24, 2018 21:08
Render Documents with Folder info and sub folder 2 levels
@model Telerik.Sitefinity.Frontend.Media.Mvc.Models.DocumentsList.DocumentsListViewModel
@using System;
@using System.Linq;
@using System.Runtime;
@using Telerik.Sitefinity.Frontend.Mvc.Helpers;
@using Telerik.Sitefinity.Frontend.Media.Mvc.Models.DocumentsList;
@using Telerik.Sitefinity.Libraries.Model;
@using Telerik.Sitefinity.Modules.Libraries;
@using Telerik.Sitefinity;
@jonathanread
jonathanread / Global.asax
Created August 24, 2018 21:04
Render OG Fields to Page Head
using SitefinityWebApp.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Routing;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Frontend;
using Telerik.Sitefinity.Frontend.Navigation.Mvc.Models;
@jonathanread
jonathanread / ReplaceUserName.cshtml
Created July 16, 2018 14:53
Replace a UserName key in a content block with the logged in users User Name
@model Telerik.Sitefinity.Frontend.ContentBlock.Mvc.Models.IContentBlockModel
@using Telerik.Sitefinity.Frontend.Mvc.Helpers
@using Telerik.Sitefinity.Security.Claims;
<div class="@Model.WrapperCssClass" @Html.InlineEditingAttributes(Model.ProviderName, Model.ContentType, Model.SharedContentID)>
<div @Html.InlineEditingFieldAttributes("Content", "LongText")>@ReplaceUserName(Model.Content)</div>
@{
if (Model.EnableSocialSharing)
{
@Html.SocialShareOptions(null);
}
@jonathanread
jonathanread / google-pin-map.html
Created April 30, 2018 20:19
Sitefinity Example of pin good map using odata service
<style>
#content h1.storeName {
font-size: 24px;
margin: 0 0 5px 0;
padding: 0;
line-height: 1em
}
#content h1.storeName:hover {
cursor: pointer;
@jonathanread
jonathanread / ToolboxConfigHelper.cs
Created March 13, 2018 20:33
This updated a specific Toolbox section and tool to 'disable' them. Specifically created to work around issue with UI not updating custom content type tool items
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Modules.Pages.Configuration;
namespace SitefinityWebApp.Helpers
{
public static class ToolboxConfigHelper
@jonathanread
jonathanread / MultisiteHelpers.cs
Last active January 5, 2018 13:03
Static helper class to retrieve provider name for current site and to get current site id
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Multisite;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Utilities.TypeConverters;
namespace SitefinityWebApp.Helpers
@jonathanread
jonathanread / GetDocsByTag.aspx
Created November 21, 2017 15:00
Search Sitefinity Documents by Tag Name
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetDocsByTag.aspx.cs" Inherits="SitefinityWebApp.Sitefinity.GetDocsByTag" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">