Skip to content

Instantly share code, notes, and snippets.

View abjerner's full-sized avatar

Anders Bjerner abjerner

View GitHub Profile
@abjerner
abjerner / PreValueEditor.html
Created October 13, 2014 19:47
Example of a quick Umbraco package
<div ng-controller="PreValueEditor.Controller">
<label>
<input type="checkbox" ng-model="model.value.a" />
Option A
</label>
<label>
<input type="checkbox" ng-model="model.value.b" />
Option B
@abjerner
abjerner / Contour.md
Created December 3, 2014 18:29
Quick guide to insert Contour <script> tags at the bottom of the page rather than in context.

Open /umbraco/plugins/umbracoContour/views/Form.cshtml and look for the following line:

@Html.Partial(FormViewResolver.GetScriptView(Model.FormId), Model)

Replace it with these lines:

List temp = HttpContext.Current.Items["ContourScripts"] as List;

By using my Skybrud.Umbraco.GridData package (which introduces a strongly typed model for the Grid), indexing the new Grid in Umbraco 7.2 is quite easy.

At Skybrud.dk we typically create a class named ExamineIndexer that takes care of the Examine related events. This class should be initalized during Umbraco startup like this:

using Umbraco.Core;

namespace FanoeTest {

 public class Startup : ApplicationEventHandler {
@abjerner
abjerner / Dashboard.md
Created January 19, 2015 18:40
Adding a dashboard for a custom section

Open /config/Dashboard.config, then add something like:

<section alias="CustomDashboardSection">
  <areas>
    <area>myApp</area>
  </areas>
  <tab caption="Welcome">
    <control addPanel="true" panelCaption="">
/App_Plugins/myApp/dashboard.html
  • Create a common package - could be called Our.NuGetPackageActions for packages to use. Ths package:

    • Looks for packages at startup (eg. implementing a certain interface)

    • Keeps track of new install and updates via temp files stored in App_Data sub folder

  • Lets you have events for "Installed" and "Updated". There could also be an "Uninstalled" event although the DLL has been removed ad this point.

@abjerner
abjerner / Translations.js
Created April 22, 2015 08:31
Adding custom translations to Umbraco backoffice
$(window).load(function () {
var ev = angular.element(document).injector().get('eventsService');
ev.on('localizationService.updated', function () {
var ls = angular.element(document).injector().get('localizationService');
ls.dictionary['bacon_omgbacon'] = 'OMG BACON';
@abjerner
abjerner / Members.cshtml
Created June 19, 2015 17:42
Listing all members in Umbraco:
@using Umbraco.Core.Services
@inherits UmbracoViewPage
@{
IMemberService ms = UmbracoContext.Application.Services.MemberService;
int total;
foreach (IMember member in ms.GetAll(0, Int32.MaxValue, out total)) {
@abjerner
abjerner / UmbracoGuidExtensions.cs
Created July 15, 2015 17:56
UmbracoGuidExtensions.cs
using System;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.PublishedCache;
public static class UmbracoGuidExtensions {
/// <summary>
/// Gets an instance of <code>IPublishedContent</code> based on the specified <code>guid</code>. GUIDs are not
/// available in the content cache, so a lookup will be made in the database (or the runtime cache if the GUID
@abjerner
abjerner / dependencies.md
Created September 7, 2015 07:01
Umbraco 6.1.5 NuGet dependencies

Installing Umbraco 6.1.5 directly via NuGet will cause some issues since some of the dependencies are downloaded in newer versions. Installing each dependency in the order as listed below will make sure that the dependencies are installed in the correct version.

Install-Package Newtonsoft.Json -Version 6.0.4
Install-Package Microsoft.Web.Infrastructure
Install-Package Microsoft.AspNet.Razor -Version 2.0.30506
Install-Package Microsoft.AspNet.WebPages -Version 2.0.30506
Install-Package Microsoft.AspNet.Mvc -Version 4.0.30506
Install-Package Microsoft.AspNet.Mvc.FixedDisplayModes -Version 1.0.1
Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.30506
@abjerner
abjerner / Examine.cshtml
Created December 15, 2015 08:38
Index a single content node in Examine
@using System.Xml.Linq
@using umbraco.cms.businesslogic.web
@using UmbracoExamine
@inherits UmbracoViewPage
@{
// Generate an instance of XElement to be indexed
XElement node = new Document(Model.Id).ToXDocument(false).Root;