Skip to content

Instantly share code, notes, and snippets.

@eerrecart
eerrecart / Umbraco - Get media folders with childrens
Created September 5, 2014 15:39
Umbraco - Get only image folders with childrens
Declare @folders TABLE (id int , path nvarchar(300) COLLATE SQL_Latin1_General_CP1_CI_AS)
insert into @folders
select
id, path, text
from
umbracoNode as N
INNER JOIN cmsContent as C ON C.nodeId = N.id
INNER JOIN cmsContentType as CT ON C.contentType = CT.nodeId and CT.alias = 'folder'
@eerrecart
eerrecart / Get all media ids referenced on documents using a specific properties
Created September 4, 2014 19:21
Umbraco - Get all media ids referenced on documents
-- native image picker editor data type => EF94C406-9E83-4058-A780-0375624BA7CA
DECLARE @dataTypeSearch NVARCHAR(50)
SET @dataTypeSearch = 'EF94C406-9E83-4058-A780-0375624BA7CA'
-- get all datatypes using the image picker tool
SELECT * FROM cmsDataType as DT
INNER JOIN umbracoNode N on N.id = DT.nodeId
WHERE DT.controlId LIKE @dataTypeSearch
@eerrecart
eerrecart / Umbraco - Delete nodes by Document Type
Created September 2, 2014 19:35
Umbraco - Delete Umbraco nodes by Document Type Alias
BEGIN TRAN
DECLARE @Nodes TABLE (NodeId int)
INSERT INTO @Nodes (NodeId)
SELECT top 1000 n.id
FROM cmsContent C
INNER JOIN cmsContentType CT ON C.contentType = CT.nodeId
INNER JOIN umbracoNode N ON C.nodeId = N.id
WHERE CT.alias = '[Your Document Type Alias Here]'
@eerrecart
eerrecart / Umbraco - Delete All Children of Specified Node ID
Created September 2, 2014 19:34
Umbraco - Delete All Children of Specified Node ID
/* Delete All Children of Specified Node ID */
Declare @nodeId int
Set @nodeId = 18904 /* -20 = Content Recycle Bin, -21 = Media Recycle Bin */
Declare @path varchar(500)
Set @path = (Select top 1 path from umbracoNode Where id = @nodeId)
/* If you want to delete the item as well, remove the comma from the following line. */
Set @path = @path + ',%'
@eerrecart
eerrecart / Umbraco - Delete Old Document Versions
Last active August 29, 2015 14:05
Umbraco - Delete Old Document Versions
BEGIN TRANSACTION
/* Delete Old Document Versions */
Declare @keepOldVersionsCount int, @keepNewerThanDate datetime
Set @keepOldVersionsCount = 0 /* 0 Keeps published and newest only. */
Set @keepNewerThanDate = getdate() /* getDate() or '2013-01-01' */
@eerrecart
eerrecart / Umbraco - Delete nodes from recycle bin
Last active August 29, 2015 14:05
Delete Umbraco nodes from recycle bin
BEGIN TRANSACTION
SET NOCOUNT ON
DECLARE @Nodes TABLE (NodeId int)
INSERT INTO @Nodes (NodeId)
SELECT n.id
FROM umbracoNode n
WHERE n.path like '%-20%' and id!=-20
@eerrecart
eerrecart / .net Bundling version with UseCdn = true
Last active January 3, 2016 15:09
I've made this to append a query string with a "number version" according to the assets content, so it works as Cache BUST for CDN caching services (i.e: cloudfront). It only check the last modified date of each asset inside a bundle and create a token, you can create a MD5 o change to something more cool. The code is executed wen a file changes…
/// <summary>
/// uses the BuildCundleContent to create a file midification token, but we need to keep the BaseBuilder functionality, so we
/// take them from the ctr.
/// </summary>
public class SetAssetVersion : IBundleBuilder
{
public IBundleBuilder BaseBuilder { get; set; }
public SetAssetVersion(IBundleBuilder baseBuilder)
{