Skip to content

Instantly share code, notes, and snippets.

@kevinblake
kevinblake / gist:4000628
Created November 2, 2012 11:50
Rebuild Examine Indexes on Application Start
using System.Collections.Generic;
using Examine;
using umbraco.businesslogic;
namespace MyApplication
{
public class ExamineIndexRebuild : ApplicationStartupHandler
{
@tekguy
tekguy / KoograRead.cs
Last active June 30, 2020 07:13
Read an excel file using Koogra
// This example shows how to read and excel file using the Koogra library (http://sourceforge.net/projects/koogra/)
// Supports .xls and .xlsx example
public static string ReadExcelContent(string filePath)
{
uint rowNum = 0;
uint colNum = 0;
var data = new StringBuilder();
try
{
@leekelleher
leekelleher / umbraco-find-nodes-by-property-value.sql
Last active October 3, 2017 14:10
Umbraco - Find nodes with specific property value
DECLARE @propertyAlias NVARCHAR(50);
DECLARE @search NVARCHAR(50);
SET @propertyAlias = 'bodyText';
SET @search = 'whatever';
SELECT
n.id,
n.path,
n.text
@mortenbock
mortenbock / Bootstrapper.cs
Created September 21, 2013 16:04
MiniProfiler.UmbracoMvc proof of concept. Blogpost here: http://www.mortenbock.dk/post/Profiling-MVC-views-in-Umbraco-6
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Web.Mvc;
namespace UmbMvcMiniProfiler
{
public class Bootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
@sniffdk
sniffdk / ContextHelpers.cs
Last active February 28, 2022 10:03
Fake an UmbracoContext for use when doing published scheduling or other scenarios where UmbracoContext is normally null.
public class ContextHelpers
{
public static UmbracoContext EnsureUmbracoContext() {
if (UmbracoContext.Current != null)
{
return UmbracoContext.Current;
}
var httpContext = new HttpContextWrapper(HttpContext.Current ?? new HttpContext(new SimpleWorkerRequest("temp.aspx", "", new StringWriter())));
@alindgren
alindgren / XMLSitemap.cshtml
Last active October 7, 2024 07:50
XML sitemap for Umbraco 7 (based on Cultiv Search Engine Sitemap package). See http://www.alexlindgren.com/archive/dynamically-generated-xml-sitemaps-with-umbraco-7/
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq;
@{
Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
@alindgren
alindgren / MultilingualContentFinder.cs
Last active August 13, 2018 15:24
ContentFinder for multilingual sites in Umbraco
using System;
using System.Globalization;
using System.Web;
using Umbraco.Web.Routing;
using Umbraco.Core;
public class MultilingualContentFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
@dampee
dampee / umbraco db cleanup.sql
Last active November 9, 2021 12:57
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
-- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
DELETE FROM cmsPropertyData WHERE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Web.Routing;
namespace Diplo.Core
{
/// <summary>
@glcheetham
glcheetham / UmbracoApplication.cs
Created May 27, 2016 21:41
Umbraco IOC Implementation that works properly
using Autofac;
using Autofac.Integration.Mvc;
using Autofac.Integration.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using MyApp.Services;
using MyApp.Services.Interfaces;