Skip to content

Instantly share code, notes, and snippets.

View naepalm's full-sized avatar

Janae Cram naepalm

View GitHub Profile
@naepalm
naepalm / TastyCookies.js
Last active August 23, 2016 21:06
Kyle's handy-dandy cookie scripts.
/**
* @class Cookie
* @description Helper functions for adding and deleting cookies.
*/
var Cookie = {
/**
* @method delete
* @param {string} cookieName - The name of the cookie to delete.
* @description Deletes the indicated cookie.
*/
@naepalm
naepalm / RazorServerDirectoryListingHelper.cshtml
Created August 17, 2016 16:45
Displays a list of directories and files on a server, for those nasty moments when you don't have access and are looking for something.
@helper RenderFolders(string dirPath, bool displaySubDirs = false)
{
try
{
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
<h4>@string.Format("Directory: {0}", dirPath.Substring(dirPath.LastIndexOf("\\") + 1))</h4>
<p>@(string.Format("{0} directories found.", dirs.Count))</p>
<ul>
@foreach (var dir in dirs)
@naepalm
naepalm / TextOverImagePartial.cshtml
Created January 12, 2017 22:10
Files to easily render the Text Over Image Editor on the front.
@model TextOverImage.Models.ImageWithText
@{
// Use this code to render this partial in your template. Replace "banner" with whatever your property name is
// Make sure to include @using TextOverImage.Models at the top of your template
//@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
//{
// @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
//}
@naepalm
naepalm / DictionaryController.cs
Created February 8, 2017 18:08
Get all dictionary items for a language on a site and spit them out in an API Controller.
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Web;
using Umbraco.Web.WebApi;
namespace Olympic.Web.Controllers.Api
{
public class DictionaryController : UmbracoApiController
{

Skrift headquarters resides in Bellingham, WA, at whatever restaurant or coffee house of choice suits Erica, Janae, and Kyle for their weekly meetings. At it's core, the magazine was contrived to bring the global Umbraco community together and find a localized place to promote uWestFest and other festivals around the world. Having worked together for seven years, each member of the team brings their own unique skills to Skrift's management. As a freelance UX designer, Erica is in charge of design, user testing, and statistics, Janae specializes in the C#, HTML, and CSS of the site as their resident code junkie, and Kyle puts his skills to use both as their Javascript guru and Editor In Chief (he's an award winning journalist and cartoonist, you know!*). Passionate about the web and Umbraco with skills developed working together in an agency bef

@naepalm
naepalm / ZoomAreaCropperView.cshtml
Last active May 26, 2017 16:58
A simple example of how to use the Zoom Area Cropper in a view.
@inherits UmbracoTemplatePage
@using ZoomAreaCropper.Models
@{
Layout = null;
}
@if (Model.Content.HasValue("photo"))
{
var photo = Model.Content.GetPropertyValue<ZoomAreaCropper>("photo");
if (photo.HasMedia)
@naepalm
naepalm / DocTypeGridEditorReusableContentExample.cshtml
Created June 8, 2017 20:19
An example for how a DocType Grid Editor partial view should look with the DTGE: Reusable Content Extension
@inherits UmbracoTemplatePage
@{
// Set a variable to use the default content if no linked content has been selected
var content = Model.Content;
// Check to see if there's a linked page value
if(Model.Content.HasProperty("dtgeLinkedId") && Model.Content.HasValue("dtgeLinkedId"))
{
// Run the linked page value through Umbraco.TypedContent() to get the IPublishedContent page
var dtgePage = Umbraco.TypedContent(Model.Content.GetPropertyValue("dtgeLinkedId"));
@naepalm
naepalm / GridExtensions.cs
Last active July 20, 2017 15:48
Grid extensions for use with Ditto, Skybrud, DocType Grid Editor, and the DocType Grid Editor Reusable Content package
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Our.Umbraco.Ditto;
using Offroadcode.Web.Models.Widgets;
using Skybrud.Umbraco.GridData;
using Skybrud.Umbraco.GridData.Values;
using Umbraco.Core.Models;
using Umbraco.Web;
@naepalm
naepalm / ExampleCode.cshtml
Last active August 3, 2017 16:35
The handy CheckboxListFor Html extension.
@using(Html.BeginUmbracoForm<ExampleSurfaceController>("SubmitForm", FormMethod.Post))
{
@Html.CheckBoxListFor(x => x.CheckboxListField, Model.CheckboxListSelectItems)
<button type="submit">Submit</button>
}

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: