Skip to content

Instantly share code, notes, and snippets.

View brendan-rice's full-sized avatar

Brendan Rice brendan-rice

View GitHub Profile
{"title":"6 Bed Detached House","category":{"id":248,"parentId":87,"name":"Detached House","isCategory":false,"order":1,"subCategories":[],"adTypeCategoryGroupId":1,"propertyTypeId":1,"adTypeId":1008,"isAuction":false},"adTypeName":"For Sale - Residential","isAuction":false,"description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ultrices mattis turpis, at rutrum neque molestie nec. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam scelerisque, justo laoreet fringilla congue, nulla lectus consectetur quam, in auctor massa felis ut tortor. Curabitur diam ante, mattis non consequat vitae, varius in nibh. \n\nCras nunc velit, fermentum a volutpat sed, dictum in sem. Aliquam nulla lacus, lobortis nec enim vel, laoreet mollis diam. Proin tristique urna vel arcu egestas, ut lacinia magna vulputate. Nam sollicitudin feugiat eros, non varius tellus consequat egestas.\n\nSed porta est enim, eget volutpat tortor sollicitudin eget. Mauris at arcu nec erat fermentum sagittis sodales
@brendan-rice
brendan-rice / DontShout.cs
Created July 2, 2021 20:41 — forked from warrenbuckley/DontShout.cs
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)
@brendan-rice
brendan-rice / QandA.cshtml
Created July 2, 2021 20:20 — forked from tristolliday/QandA.cshtml
Newtonsoft Json.NET for Structured Data - Google Rich Snippets and Enhanced SEO
@using Newtonsoft.Json.Linq
@{
var questions = Model.Value<IEnumerable<IPublishedElement>>("questions");
}
<script type="application/ld+json">
@{
var structuredData =
new JObject(
new JProperty("@context", "https://schema.org"),
@brendan-rice
brendan-rice / Umbraco9Images.cshtml
Created July 2, 2021 20:19 — forked from tristolliday/Umbraco9Images.cshtml
Responsive, high performance images in umbraco 9
@* /Views/Partials/ResponsiveImage.cshtml *@
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@using Umbraco.Cms.Core.Media
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.Routing
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@inject IImageUrlGenerator ImageUrlGenerator
@{
<rewrite>
<!-- Have a bunch of redirects? Put them in a separate file -->
<rules configSource="Rewrites.config" />
<rules>
<!-- Simple rewrite -->
<rule name="Simple redirect" stopProcessing="true">
<match url="^path/sub path/page\.aspx$" />
<action type="Rewrite" url="/newpath.aspx" />
@brendan-rice
brendan-rice / Start-AzureVMsOnSchedule
Created August 14, 2019 14:07 — forked from sitereactor/Start-AzureVMsOnSchedule
Powershell script for starting Azure VMs on a schedule in an Azure Automation runbook
workflow Start-AzureVMsOnSchedule {
param(
# The name of the VM(s) to start on schedule. Can be wildcard pattern.
[Parameter(Mandatory = $true)]
[string]$VMName,
# The service name that $VMName belongs to.
[Parameter(Mandatory = $true)]
[string]$ServiceName,
@brendan-rice
brendan-rice / web.config.xml
Created July 23, 2019 13:58 — forked from kipusoep/web.config.xml
SEO redirects for web.config
<!-- SEO rules (from: http://www.seomoz.org/blog/what-every-seo-should-know-about-iis#chaining) -->
<!-- SEO | Section 1 | Whitelist -->
<rule name="Whitelist - Resources" stopProcessing="true">
<match url="^(?:css/|scripts/|images/|install/|config/|umbraco/|umbraco_client/|base/|webresource\.axd|scriptresource\.axd|__browserLink|[^/]*/arterySignalR/.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<!-- SEO | Section 2 | Rewrites (chaining) -->
<rule name="SEO - Remove default.aspx" stopProcessing="false">
<match url="(.*?)/?default\.aspx$" />
@brendan-rice
brendan-rice / ContactForm.cs
Created January 11, 2019 15:08 — forked from naepalm/ContactForm.cs
Contact Form for Umbraco with a Departments dropdown list. Assumes the dropdown list is NestedContent on the selected Email Template.
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
namespace Forms.Web.Models
{
public class ContactForm
{

How to set up ModelsBuilder & AutoMapper on a Project

AutoMapper is used to map the ModelsBuilder Api to Umbraco ViewModels. Dave Woestenborghs has written an excellent article on 24 Days that you can read for more information. This step-by-step is basically a paired down version of his article and a heads up for gotchas we encountered when setting up our project.

Step 1: Install the Visual Studio Extension for ModelsBuilder

(If this isn't your first project using this method, you already have this installed, so don't worry about it!)

Download and Install Stephan's custom ModelsBuilder tool for VS:

box-shadow: 0 0 1px rgba(9, 30, 66, 0.31), 0 20px 32px -8px rgba(9, 30, 66, 0.25);