Skip to content

Instantly share code, notes, and snippets.

View warrenbuckley's full-sized avatar

Warren Buckley warrenbuckley

View GitHub Profile
@warrenbuckley
warrenbuckley / UpdateAllMembersWithNewMemberGroup.sql
Created April 24, 2024 15:53
Umbraco: Add a NEW member group to all members who do not have the group already assigned
-- Variables --
DECLARE @memberGroup VARCHAR(100) = 'PORTAL MEMBER'
DECLARE @memberGroupIntId INT
DECLARE @nodeId INT
-- Get the INT ID of the member group that is called 'Portal Member' --
SELECT @memberGroupIntId = [id]
FROM [dbo].[umbracoNode]
WHERE nodeObjectType = '366E63B9-880F-4E13-A61C-98069B029728' -- This GUID is for member groups --
@warrenbuckley
warrenbuckley / gist:2401077
Created April 16, 2012 19:55
Umbraco V5 - Show Notification Bubble in JS
//Display an Umbraco message bubble notification bottom right from JavaScript
//.showNotifications() takes a JSON object so an AJAX could return this JSON for notification bubble
//Success
$u.Sys.NotificationManager.getInstance().showNotifications([{ title: 'Hey!', message: 'Hello There', type: 'success'}]);
//Info
$u.Sys.NotificationManager.getInstance().showNotifications([{ title: 'Some info', message: 'I have something to say', type: 'info'}]);
//Error
@warrenbuckley
warrenbuckley / AuthorContentIndexer.cs
Created May 24, 2023 12:18
Umbraco V12: Extending Content Delivery API
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Web;
namespace ExampleProject.ContentDeliveryApi
{
public class AuthorContentIndexer : IContentIndexHandler
{
private readonly IUmbracoContextFactory _umbracoContextFactory;
@warrenbuckley
warrenbuckley / appsettings.development.json
Created November 7, 2022 12:22
Example V9+ Umbraco CMS Serilog Configuration to write to additional File location
{
"$schema" : "./appsettings-schema.json",
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Examine.Lucene.Providers.LuceneIndex": "Debug",
"Examine.BaseIndexProvider": "Debug",
"Examine.Lucene.LoggingReplicationClient": "Debug",
"Examine.Lucene.ExamineReplicator": "Debug"
@warrenbuckley
warrenbuckley / StaticAssetsHeaders.cs
Created September 22, 2022 11:13
Showing how to use ASP.NET Static Assets options to set custom headers on files with Umbraco
using Microsoft.Net.Http.Headers;
using Umbraco.Cms.Core.Composing;
namespace StaticAssets
{
public class StaticAssetsHeaders : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.Configure<StaticFileOptions>(options =>
@warrenbuckley
warrenbuckley / appsettings.json
Created May 3, 2022 14:47
Umbraco 9+ appsettings.json configuration to remove init HTML P tags in TinyMCE RTE
{
"$schema": "./umbraco/config/appsettings-schema.json",
"Umbraco": {
// NOTE: Other settings removed in this example for clarity
"CMS": {
"RichTextEditor": {
"CustomConfig": {
"forced_root_block": ""
}
}
@warrenbuckley
warrenbuckley / DatabaseExample.cs
Created February 4, 2019 11:12
Super simple example of using Database inside Umbraco V8
using Umbraco.Core.Scoping;
namespace My.Website
public class DatabaseExample
{
private IScopeProvider _scopeProvider;
public DatabaseExample(IScopeProvider scopeProvider)
{
_scopeProvider = scopeProvider;
@warrenbuckley
warrenbuckley / MyCustomIdentityErrorDescriber.cs
Last active July 27, 2021 15:13
.NET Core Identity PasswordValidators with Umbraco CMS BackOffice Users
using Microsoft.AspNetCore.Identity;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.UI.NetCore
{
public class MyCustomIdentityErrorDescriber : BackOfficeErrorDescriber
{
private ILocalizedTextService _textService;
@warrenbuckley
warrenbuckley / winget.ps1
Last active July 20, 2021 10:58
WinGet install Powershell script
winget install --id=Spotify.Spotify -e ;
winget install --id=Microsoft.WindowsTerminal -e ;
winget install --id=Microsoft.VisualStudioCode -e ;
winget install --id=7zip.7zip -e ;
winget install --id=Microsoft.AzureStorageExplorer -e ;
winget install --id=ScooterSoftware.BeyondCompare4 -e ;
winget install --id=Google.Chrome -e ;
winget install --id=Dropbox.Dropbox -e ;
winget install --id=Git.Git -e ;
winget install --id=Insomnia.Insomnia -e ;
@warrenbuckley
warrenbuckley / DontShout.cs
Created May 5, 2021 10:49
Umbraco V9 Event to Notification Handler Example
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Infrastructure.Services.Notifications;
namespace TestingEvents
{
public class DontShout : INotificationHandler<ContentPublishingNotification>
{
public void Handle(ContentPublishingNotification notification)
{
foreach (var node in notification.PublishedEntities)