Skip to content

Instantly share code, notes, and snippets.

@sleslie321
sleslie321 / nested_menu.cs
Created September 20, 2013 21:23
Umbraco 6 Razor Nested Menu
@{ var SectionPage = CurrentPage.AncestorOrSelf(2);}
<h2><a href="@SectionPage.Url" title="@SectionPage.Name">@SectionPage.Name</a></h2>
<ul class="nav">
@foreach( var page in SectionPage.Children.Where("Visible"))
{
<li>
<a href="@page.Url" class="@(page.Id == CurrentPage.Id ? "selected":null)" title="@page.Name">@page.Name</a>
</li>
@sleslie321
sleslie321 / gist:6645139
Last active December 23, 2015 13:49
Umbraco 6 Razor Breadcrumb Trail
<ol class="breadcrumb">
<li>You are here:</li>
@foreach (var ancestor in CurrentPage.Ancestors().Where("Visible"))
{
<li><a href="@ancestor.Url" title="@ancestor.Name">@ancestor.Name</a> > </li>
}
<li class="active">@CurrentPage.Name</li>
</ol>
@sleslie321
sleslie321 / gist:8670558
Last active January 4, 2016 19:59
Umbraco - list of tags via Razor
@using umbraco.cms.businesslogic.Tags
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var blogTags = Tag.GetTags("default").OrderByDescending(t => t.NodeCount);
}
<h4>Tags</h4>
<ul>
@foreach (var t in blogTags)
{
<li><a href='/tag?tag=@t.TagCaption' title='@t.TagCaption'>@t.TagCaption (@t.NodeCount)</a></li>
@sleslie321
sleslie321 / rss.feed.cshtml
Created August 23, 2014 14:12
Create RSS Feed from Document Type in Umbraco using Razor
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{umbraco.library.ChangeContentType("text/xml");
var siteURL = "http://" + Request.Url.Host;
var HomePage = CurrentPage.AncestorOrSelf(1);
var RSSFeedPubDate = HomePage.Descendants("PressRelease").OrderBy("publishedDate desc").First();
}<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rssdatehelper="urn:rssdatehelper">
@sleslie321
sleslie321 / rss.php
Created October 7, 2014 17:55
Consume RSS feed with php
<?php
$rss = new DOMDocument();
$rss->load('http://feeds.bbci.co.uk/news/rss.xml');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Examine
@using Examine.SearchCriteria
@using Examine.LuceneEngine.SearchCriteria
@{
//Get search query
var q = Request.QueryString["q"];
//Check if searchQuery is null from the posted form data...
if (q == null)
@sleslie321
sleslie321 / CustomDataService.cs
Last active August 4, 2016 20:39
Use Examine to index and search any data source.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simple.Data;
using Examine.LuceneEngine;
using Examine;
@sleslie321
sleslie321 / MultiNodeTreePickerIdToUdiMigrator.cs
Created August 22, 2022 12:43
Migrate Ids to Udis for Umbraco.MultiNodeTreePicker
using System;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Web;
namespace Sniper.Umbraco
{
public static class MultiNodeTreePickerIdToUdiMigrator
{