Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
@fluxdigital
fluxdigital / InitialiseHost.cs
Created November 7, 2018 18:37
Pipeline to Initialise a Telligent Host
public class InitialiseHost
{
public virtual void Process(PipelineArgs args)
{
Host.Get("default").ResolveLocalUser = (host, resolveArgs) =>
{
if (Context.User == null || !Context.User.IsAuthenticated)
return null;
return new LocalUser(Context.User.LocalName, Context.User.Profile.Email);
@fluxdigital
fluxdigital / TelligentRestHost.cs
Last active November 18, 2018 21:55
Custom Rest Host for Telligent Community that uses an API Key for access
public class TelligentRestHost : Telligent.Evolution.Extensibility.Rest.Version1.RestHost
{
private string _communityUrl = null;
private string _adminAPIKey = null;
private string _adminUserName = null;
private bool _impersonate = false;
private string _impersonateUsername = null;
private string _requestTimeoutSeconds = null;
public TelligentRestHost(string communityUrl, string adminUserName, string adminApiKey, bool impersonate, string requestTimeoutSeconds, string impersonateUsername = "")
@fluxdigital
fluxdigital / MvcBrowserCaching.cs
Last active November 9, 2018 18:48
Fix for MvcBrowserCaching not working on 8.1 and 8.2
public class MvcBrowserCaching : GetPageRenderingProcessor
{
public override void Process(GetPageRenderingArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
Profiler.StartOperation("Update browser caching headers.");
HttpContext currentContext = HttpContext.Current;
Item currentItem = PageContext.CurrentOrNull.Item;
if (currentContext == null)
@fluxdigital
fluxdigital / BlogPostList.ascx
Last active November 18, 2018 22:20
Telligent Community Blog Post List
@using System.Web.Mvc
@using System.Web.Mvc.Html
@model TcDemo.Models.TcBlogPost
<section>
@foreach (TcDemo.Models.TcBlogPost post in Model){
<div>
<h1>
<a href="@post.Url">@Html.Raw(post.Title)</a>
</h1>
@fluxdigital
fluxdigital / TcBlogPost.cs
Created November 18, 2018 20:32
Telligent Community Blog Post
public class TcBlogPost : TcPostBase
{
public string Slug { get; set; }
public string Title { get; set; }
public string TitleUrl { get; set; }
public string PublishedDate { get; set; }
public string ExcerptSize { get; set; }
public string UsePostSummary { get; set; }
public string GeneratePostSummary { get; set; }
public string BlogId { get; set; }
@fluxdigital
fluxdigital / TcPostBase.cs
Created November 18, 2018 20:34
Base Telligent Community Post
public class TcPostBase
{
public string Id { get; set; }
public string ContentId { get; set; }
public string ContentTypeId { get; set; }
public string Url { get; set; }
public string Excerpt { get; set; }
public string Body { get; set; }
public string GroupId { get; set; }
public string IsFeatured { get; set; }
@fluxdigital
fluxdigital / Swap-Remove-Page-Renderings.ps1
Last active December 17, 2018 23:37
SPE script to swaps one rendering for another and also deletes an rendering if required and updates datasources
$rootItem = Get-Item -Path "/sitecore/templates/Site1/Pages" #update to the path with your page templates
$deviceLayout = Get-LayoutDevice "Default" #update to device layout you wish to target
$templateMode = $True #set to False to update pages instead of templates (usually you will want to update template standard values)
$useFinalLayout = $False #set to True to use FinalRenderings instead of Renderings field
$checkForLayout = $False #set to True to skip items with no layout (use only for updating pages and not templates)
$updateDataSourcesOnly = $False #set to True to only update datasources and not swap or delete renderings
$reportMode = $False #set to True to just output info on renderings to be swapped/deleted/updated
$modeType = ""
$placeholder = "main" #update to use the placeholder your renderings exist in
$renderingIdToSwap = "{15BCE4DA-4F3C-42CA-9D4D-D46D572C7A8F}" #update to the rendering id you wish to swap out
public class CustomDropDownList : DropList
{
private static readonly string BaseCssClassName = "scfCustomlistBorder";
[ParameterName("emptychoicetext")]
[VisualCategory("Custom")]
[VisualProperty("Empty Choice Text:")]
public string EmptyChoiceText { get; set; }
[ParameterName("showemptychoice")]
@fluxdigital
fluxdigital / CustomDropDownListField.cs
Created November 28, 2018 14:35
WFFM custom drop down field (used in MVC)
public class CustomDropDownListField : DropListField
{
public CustomDropDownListField()
{
//initalise services here
}
private string InitialSelection { get; set; }
public override void Initialize()
@fluxdigital
fluxdigital / Swap-Rendering-Function.ps1
Created December 17, 2018 23:15
Swaps one rendering for another and optionally swaps out the datasource too
function Swap-Rendering ($item, $renderingToSwapOut, $placeholder, $renderingIdToAdd, $renderingDataSourceIdToAdd, $useFinalLayout) {
$renderingItem = Get-Item -Path $renderingToSwapOut.ItemID
Write-Host "Swaping Rendering: $($renderingToSwapOut.UniqueID) - '$($renderingItem.Name)' in Placeholder: $($placeholder) to: $($renderingIdToAdd) - '$($renderingToAdd.Name)' for Item: $($item.Name)"
$renderingToSwapOut.ItemID = $renderingIdToAdd
if($renderingDataSourceToAdd){
$renderingToSwapOut.Datasource = $renderingDataSourceToAdd
}
Set-Rendering -Item $item -Instance $renderingToSwapOut -FinalLayout:$useFinalLayout
}