Skip to content

Instantly share code, notes, and snippets.

@PNergard
PNergard / Layout.cshtml
Last active February 4, 2025 08:41
Optimizely PageCriteriaQueryService builder
@using BlazorLabs.Cms.BlazorComponents
@using EPiServer.Framework.Web.Mvc.Html
@using System.Diagnostics.Metrics
<!DOCTYPE html>
<html lang="@(Model.CurrentPage.Language)">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@PNergard
PNergard / SiteStatistics.razor
Last active January 28, 2025 08:37
Optimizely content statistics graph-component
@page "/sitestatistics"
@using EPiServer.Web
@using MudBlazor.Charts
@inject IContentLoader _contentLoader
@inject IContentTypeRepository _contentTypeRepository
@inject ISiteDefinitionRepository _siteDefinitionRepository
<h3>Some basic site content metrics</h3>
@PNergard
PNergard / OrphanContentCleaner.razor
Last active May 27, 2025 16:32
Orphan content cleaner for Optimizely - Blazor style
@using EPiServer.Globalization
@using EPiServer.Web
@using EPiServer.Web.Routing
@inject IContentLoader _contentLoader
@inject IContentRepository _contentRepository
@inject UrlResolver _urlResolver
@inject LanguageResolver LanguageResolver
<MudPaper Class="outer-paper" Width="100%" Height="100vh" Elevation="0">
@PNergard
PNergard / BlazorLayout.cshtml
Created January 12, 2025 07:17
Optimizely drag and drop tab sorter
@using BlazorLabs.Cms.BlazorComponents
@using EPiServer.Framework.Web.Mvc.Html
@using System.Diagnostics.Metrics
<!DOCTYPE html>
<html lang="@(Model.CurrentPage.Language)">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@PNergard
PNergard / ImageAltValidator.cs
Created January 7, 2025 13:43
Optimizely Validation attribute for checking a image "alt"-text property before publishing
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer.Validation;
using EPiServer.Web.Routing;
using HtmlAgilityPack;
using Pure.Core.Models.Media;
using System;
using System.Collections.Generic;
@PNergard
PNergard / Cleaner.aspx
Created June 17, 2019 13:33
Content cleaner. A Episerver admin mode plugin to let you find content of a specific type and delete all or selected instances
<%@ Page Language="c#" CodeBehind="Cleaner.aspx.cs" AutoEventWireup="False" Inherits="LatestEpi.modules.TypeContentCleaner.Cleaner" Title="" %>
<%@ Import Namespace="EPiServer.Web.Mvc.Html" %>
<asp:content contentplaceholderid="MainRegion" runat="server">
<asp:HiddenField runat="server" id="SelectedScheduledJobGUID" ClientIDMode="static" />
<asp:HiddenField runat="server" id="SelectedMedia" ClientIDMode="static" />
<script type="text/javascript">
using EPiServer;
using EPiServer.Core;
using EPiServer.SpecializedProperties;
using EPiServer.Web.Routing;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.ModelBinding;
@PNergard
PNergard / SelectManyContentReferenceValidator.cs
Last active February 19, 2019 15:10
An attribute and a IValidate class that gives the developer the options to point out an IList<ContentReference> property from a string property decorated with a SelectMany attribute so when the editor changes the selectmany property the string contentreferences are added to the IList property so we get an automatically check that a SelectMany un…
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.ServiceLocation;
using EPiServer.Validation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
@PNergard
PNergard / Basket.aspx
Created November 9, 2017 12:23
Episerver wastebasket plugin that let admins do simple filtering and delete a single content instead of emptying the whole wastebasket.
<%@ Page Language="c#" CodeBehind="Basket.aspx.cs" AutoEventWireup="False" Inherits="NergardPlayGround.modules.WasteBasket.Basket" Title="" %>
<%@ Import Namespace="EPiServer.Web.Mvc.Html" %>
<asp:content contentplaceholderid="HeaderContentRegion" runat="server">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
@PNergard
PNergard / LogViewer.aspx
Created September 14, 2017 19:56
A Episeserver admin mode plugin that let's you see all log messages for a scheduled job instead of having to use paging
<%@ Page Language="c#" CodeBehind="LogViewer.aspx.cs" AutoEventWireup="False" Inherits="LatestEpi.modules.ScheduledJobLogViewer.LogViewer" Title="Title" %>
<%@ Import Namespace="EPiServer.DataAbstraction" %>
<asp:content contentplaceholderid="MainRegion" runat="server">
<script type="text/javascript">
function SetSelected() {
$('#SelectedScheduledJobGUID').val($('#JobSelector').val());
//console.log($('#JobSelector option:selected').text());