Skip to content

Instantly share code, notes, and snippets.

View nul800sebastiaan's full-sized avatar
🔥

Sebastiaan Janssen nul800sebastiaan

🔥
View GitHub Profile
@nul800sebastiaan
nul800sebastiaan / Umbraco RSS feed example
Created April 20, 2011 14:58
Replace "//Article" with the nodeTypeAlias of which you want to create RSS items. Note that the "bodyText" property alias is being used for the article content.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
exclude-result-prefixes="msxml umbraco.library">
@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" /> ==
<!--
@nul800sebastiaan
nul800sebastiaan / RemovePreviewButton.cs
Created July 4, 2011 10:53
Remove preview button in Umbraco
using System;
using umbraco.BusinessLogic;
using umbraco.presentation.masterpages;
namespace SomeCompanyName.EventHandlers
{
public class RemovePreviewButton : ApplicationBase
{
public RemovePreviewButton()
{
@nul800sebastiaan
nul800sebastiaan / gist:1067257
Created July 6, 2011 13:47
Grouping in Razor (Umbraco 4.7.1)
@foreach(var group in Model.Children.InGroupsOf(2))
{
<div class="row-of-two">
@foreach(var item in group)
{
<span>@item.Name</span>
}
</div>
}
@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')" />