Skip to content

Instantly share code, notes, and snippets.

View jcdcdev's full-sized avatar

James jcdcdev

View GitHub Profile
@jcdcdev
jcdcdev / umbraco-version-stats.sh
Created August 6, 2023 23:50
Umbraco Version Git
#!/bin/bash
# Clone the repo to a temporary directory
git clone https://github.com/umbraco/Umbraco-CMS.git /tmp/umbraco
# Change to the repo directory
cd /tmp/umbraco
# Ask the user for the start tag
echo "Enter the start tag (semver part only):"
@jcdcdev
jcdcdev / BasicDashboard.cs
Created August 22, 2023 21:49
Umbraco.Community.SimpleDashboards - Example #1
using Umbraco.Community.SimpleDashboards.Core;
public class BasicDashboard : SimpleDashboard { }
@jcdcdev
jcdcdev / Basic.cshtml
Created August 22, 2023 21:50
Umbraco.Community.SimpleDashboards - Example #2
@inherits Umbraco.Community.SimpleDashboards.DashboardViewPage
<h1>Hello Umbraco</h1>
<p>My Dashboard alias is: @Model.Dashboard.Alias</p>
@jcdcdev
jcdcdev / BasicDashboard.cs
Created August 22, 2023 21:59
Umbraco.Community.SimpleDashboards - Example #3
using Umbraco.Community.SimpleDashboards.Core;
// Control order of where dashboard shows
[Umbraco.Cms.Core.Composing.Weight(-100)]
public class BasicDashboard : SimpleDashboard
{
public BasicDashboard()
{
// Set dashboard name
SetName("Example Dashboard Name (default)");
@jcdcdev
jcdcdev / ExampleContentTypeOrganiseAction.cs
Last active November 21, 2023 16:10
Back Office Organiser Example
using jcdcdev.Umbraco.Core.Extensions;
using StackExchange.Profiling.Internal;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
namespace Umbraco.Community.BackOfficeOrganiser.Organisers.ContentTypes;
public class ExampleContentTypeOrganiseAction : IContentTypeOrganiseAction
{
// Handle all but container types (Folders)
@jcdcdev
jcdcdev / BasicContentApp.cs
Created November 21, 2023 16:05
Simple Content Apps - Example Content App
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Community.SimpleContentApps.Core;
namespace Umbraco.Community.SimpleContentApps.TestSite;
public class BasicContentApp : ISimpleContentApp
{
public string Icon => Cms.Core.Constants.Icons.Content;
public bool ShowInContent => true;
@jcdcdev
jcdcdev / Basic.cshtml
Created November 21, 2023 16:05
Simple Content Apps - Example Content App View
@using Umbraco.Community.SimpleContentApps.Core.Extensions
@inherits Umbraco.Community.SimpleContentApps.Web.SimpleContentAppViewPage
<h1>Hello Umbraco</h1>
<p>My ContentApp alias is: @Model.ContentApp.Alias()</p>
@jcdcdev
jcdcdev / appsettings.json
Created December 1, 2023 00:14
Umbraco Unattended Upgrades
{
"Umbraco": {
"CMS": {
"Unattended": {
"PackageMigrationsUnattended": true,
"UpgradeUnattended": true
}
}
}
}
@jcdcdev
jcdcdev / appsettings.json
Created February 12, 2024 22:24
Umbraco Login Screen
{
"Umbraco": {
"CMS": {
"Content": {
// Paths relative to wwwroot/umbraco
"LoginBackgroundImage": "../umbraco-login-background.png",
"LoginLogoImage": "../umbraco-login-logo.svg",
"LoginLogoImageAlternative": "../umbraco-login-logo-alt.svg"
}
}
public class Handler(IUmbracoContextFactory umbracoContextFactory, IRelationService relationService) : INotificationHandler<ContentPublishedNotification>
{
public void Handle(ContentPublishedNotification notification)
{
using var umbracoContext = umbracoContextFactory.EnsureUmbracoContext().UmbracoContext;
foreach (var content in notification.PublishedEntities.Where(x => x.ContentType.Alias == Article.ModelTypeAlias))
{
if (umbracoContext.Content?.GetById(content.Id) is Article article)
{
relationService.Relate(article.Author.Id, article.Id, "authorToArticle");