Skip to content

Instantly share code, notes, and snippets.

View KevinJump's full-sized avatar
🚴

Kevin Jump KevinJump

🚴
View GitHub Profile
@KevinJump
KevinJump / SiteNavLogging
Created November 5, 2014 10:05
Adding logging to the SiteNavigationController in the uLocalGov StarterKit.
...
foreach (IPublishedContent page in sitePages){
global::Umbraco.Core.Logging.LogHelper.Info<SiteNavigationSurfaceController>("Adding Page to a-z {0}", () => page.Name);
if (!azPages.ContainsKey(page.GetPropertyValue<string>("title"))){
azPages.Add(page.GetPropertyValue<string>("title"), page.Url);
}
@KevinJump
KevinJump / ContentConverter.cs
Created April 10, 2015 21:46
Data Migration code, when moving to umbraco 7 - some content may change structure, the ContentConverter walks through the code, and attempts to move the content from one type to another...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
@KevinJump
KevinJump / gist:5041416
Created February 26, 2013 19:36
Form login for AD - that creates a user in Umbraco should they not exsit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
private void ContentTreeController_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
{
var translationMenu = e.Menu.Items.Where(x => x.Alias == "sendToTranslate").FirstOrDefault();
if (translationMenu != null)
e.Menu.Items.Remove(translationMenu);
if (sender.TreeAlias == "content")
{
var item = sender.ApplicationContext.Services.ContentService.GetById(int.Parse(e.NodeId));
@KevinJump
KevinJump / AToZLetter.cshtml
Created August 13, 2015 10:00
Umbraco Caching AtoZ Helper and Partial
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Jumoo.UmbLocalGov;
@{
var letter = Request.QueryString["letter"];
if (!string.IsNullOrWhiteSpace(letter))
{
<h2>@letter.ToUpper()</h2>
// get everthing with the letter.
@KevinJump
KevinJump / CustomGridJsonValueMapper.cshtml
Created January 4, 2018 11:36
Value Mapper for Custom JSON snippets inside Umbraco Grid Values - used by Translation Manager to import / export the text values
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jumoo.TranslatePlus.Core.Models;
using Jumoo.TranslatePlus.Core.Providers;
using Jumoo.TranslatePlus.Core.ValueMappers;
using Newtonsoft.Json;
using Umbraco.Core;
@KevinJump
KevinJump / vorto-only.cs
Last active August 22, 2018 19:14
Umbraco Translation Manager - remove everything but vorto elements from a translation job, just before it is submitted (created)
/*
n.b this code isn't really tested - but in principle will work - it may need tweaking around
the edges.
At the moment there are no TranslationNode creation events - so you have to attach this to the
job submitting event which happens just before a job is created - in practice if you are
creating jobs directly from the send to translate dialog you won't notice the diffrence.
*/
//
@KevinJump
KevinJump / StackedContentMapper.cshtml
Last active September 13, 2018 11:05
Example of a Translation Manager Value Mapper (for stacked Content) - Show how to build a more complex mapper, and pass any inner values back into other mappers (this is now in translation manager core - and supports v2 of stacked content)
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Jumoo.TranslatePlus.Core.Models;
namespace Jumoo.TranslatePlus.Core.ValueMappers
{
@KevinJump
KevinJump / IDLinkMapper.cs
Created April 25, 2019 08:50
Translation Manager - Link Mapper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jumoo.TranslationManager.Core.Models;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace Jumoo.TranslationManager.LinkUpdater.LinkMappers
/// <summary>
/// Exmaple how to go into a Translation Node once it has been created and strip properties
/// based on the document type.
///
/// In this example we remove all but vorto properties - this is actually something TM will do
/// for you on loopback sets from version 2.2 - but the principles show you how to traverse
/// the translation node, go in find values and manipulate them.
/// </summary>
public class EventSetup : ApplicationEventHandler
{