Skip to content

Instantly share code, notes, and snippets.

View nul800sebastiaan's full-sized avatar
🔥

Sebastiaan Janssen nul800sebastiaan

🔥
View GitHub Profile
@nul800sebastiaan
nul800sebastiaan / gist:1042579
Created June 23, 2011 13:58
Conditional sorting for XSLTSearch 1.0
<xsl:choose>
<xsl:when test="umbraco.library:RequestQueryString('sortbydate') != ''">
<xsl:for-each select="$matchedNodes">
<!-- sort on the page score of the node, within ALL the nodes to return (the sorting must happen before choosing the nodes for this page) -->
<xsl:sort select="@createDate" order="descending"/>
<!-- only the nodes for this page -->
<xsl:if test="position() &gt;= $startMatch and position() &lt;= $endMatch">
<xsl:call-template name="postlist" />
</xsl:if>
<xsl:comment/>
@nul800sebastiaan
nul800sebastiaan / RenderArticleList.xslt
Created June 28, 2011 11:41
XSL Parameter doesn't work in a choose?!
<xsl:template name="renderArticleList">
<xsl:param name="orderByPopularity"/>
<xsl:param name="addShowInLatestNewsList"/>
<xsl:choose>
<xsl:when test="$orderByPopularity = 'true'">
== <xsl:value-of select="$addShowInLatestNewsList" /> ==
<!--
@helper RenderCountryOptions() {
<option>Choose a country...</option>
@foreach(var region in @Model.XPath("/root/Website/CountryList/CountryList[Country[not(active = 0)]]"))
{
<optgroup label="@region.Name">
@foreach(var country in @region.Children)
{
<option>@country.Name</option>
}
</optgroup>
@nul800sebastiaan
nul800sebastiaan / gist:1170848
Created August 25, 2011 14:54
Get a specific crop using Umbraco 4.7.1 Razor engine
Given this XML:
<NewsItem id="1140" parentID="1139" level="3" writerID="0" creatorID="0" nodeType="1137" template="1138" sortOrder="1" createDate="2011-08-10T13:46:53" updateDate="2011-08-25T16:51:18" nodeName="Test newsitem" urlName="test-newsitem" writerName="admin" creatorName="admin" path="-1,1051,1139,1140" isDoc="">
<categories><![CDATA[allergy]]></categories>
<introText><![CDATA[Minime vero, inquit ille, consentit. Quod si ita se habeat, non possit beatam praestare vitam sapientia.]]></introText>
<bodyText><![CDATA[
<p>Ipsum.</p>
]]></bodyText>
<imageUpload>/media/2209/tulips.jpg</imageUpload>
<imageCrop>
@nul800sebastiaan
nul800sebastiaan / EditPage.aspx
Created September 16, 2011 12:52
Adding save button to custom tree editpage
<%@ Page Language="C#" MasterPageFile="../../masterpages/umbracoPage.Master" AutoEventWireup="True" CodeBehind="EditPage.aspx.cs" Inherits="SomeCompany.CustomTrees.EditPage" %>
<%@ Register Namespace="umbraco.uicontrols" Assembly="controls" TagPrefix="umb" %>
<asp:Content ID="Content" ContentPlaceHolderID="body" runat="server">
<umb:UmbracoPanel ID="Panel1" runat="server" hasMenu="true" Text="Edit Group">
<umb:Pane ID="Pane1" runat="server">
<umb:PropertyPanel ID="PPanel0" runat="server" Text="Name">
<asp:TextBox ID="Name" runat="server" MaxLength="150" CssClass="guiInputText guiInputStandardSize"></asp:TextBox>
</umb:PropertyPanel>
@nul800sebastiaan
nul800sebastiaan / gist:1241761
Created September 26, 2011 07:12
Modify the body tag with Razor in Umbraco
<umbraco:Macro runat="server" Language="cshtml">
<body class="@Model.NodeTypeAlias.ToLower().Replace(" ", "-")">
</umbraco:Macro>
@nul800sebastiaan
nul800sebastiaan / gist:1250799
Created September 29, 2011 14:13
XSLT boolean
<xsl:variable name="myBoolean" select="$currentPage/prop = '1'" />
<!-- Doesn't work! -->
<xsl:value-of select="myTest:GetResult($myBoolean)" />
<!-- Works.. -->
<xsl:value-of select="myTest:GetResult($currentPage/prop = '1')" />
@nul800sebastiaan
nul800sebastiaan / TVShows.cshtml
Created February 12, 2012 16:24
MyEpisodes C# asp.net RSS to iCal
@using System.Globalization
@using System.ServiceModel.Syndication
@using System.Text
@using System.Xml
@using HtmlAgilityPack
@{
var feedUrl = string.Format("http://myepisodes.com/rss.php?feed={0}&uid={1}&pwdmd5={2}", Request["feed"], Request["uid"], Request["pwdmd5"]);
var reader = XmlReader.Create(feedUrl);
var feed = SyndicationFeed.Load(reader);
if (feed == null)
@nul800sebastiaan
nul800sebastiaan / InitContentController.cs
Created February 13, 2012 15:46
Creating a content node in Umbraco v5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Umbraco.Cms.Web.Model.BackOffice.Editors;
using Umbraco.Framework;
using Umbraco.Framework.Context;
using Umbraco.Framework.Persistence.Model;
using Umbraco.Framework.Persistence.Model.Attribution.MetaData;
using Umbraco.Framework.Persistence.Model.Constants;
@nul800sebastiaan
nul800sebastiaan / WebConfigTransforms.xml
Created May 5, 2012 10:39
Transform all web.config file
<Project ToolsVersion="4.0" DefaultTargets="Transform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="Tools\Microsoft.Web.Publishing.Tasks.dll"/>
<PropertyGroup>
<SitePath>$(MSBuildProjectDirectory)\..\..\Website</SitePath>
<WebConfigTransformFile>Web.Transform.config</WebConfigTransformFile>
<OutputFolder>$(MSBuildProjectDirectory)\..\Transformed</OutputFolder>
<StackTraceEnabled>False</StackTraceEnabled>