This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This code is referenced in the following blog posts: | |
// * https://colinmackay.scot/2018/08/17/ensure-controller-actions-classes-have-authorisation/ | |
// | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()))); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
//Get the current page | |
var currentPage = DynamicModel; | |
//Will walk up the tree to the last ancestor node aka RootNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@* Check we have child pages *@ | |
@if (DynamicModel.Children.Any()) | |
{ | |
<nav id="subnavi"> | |
<ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@functions { | |
object MacroParamValueOrDefault(dynamic paramValue, object defaultValue = null) | |
{ | |
if(string.IsNullOrEmpty(paramValue)) { | |
return defaultValue; | |
} else { | |
return paramValue; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
@* Macro Param: Twitter Username that defaults to umbraco if empty *@ | |
var twitterUsername = String.IsNullOrEmpty(Model.MacroParameters.twitterUsername) ? "umbracoproject" : Model.MacroParameters.twitterUsername; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web.Macros | |
@* Added these in *@ | |
@using System.ServiceModel.Syndication | |
@using System.Xml; | |
@{ | |
// Get the remote url | |
var remoteUrl = String.IsNullOrEmpty(Model.MacroParameters.remoteURL) ? "http://feeds.feedburner.com/umbracoblog" : Model.MacroParameters.remoteURL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
//Output an image from an upload property on current doctype | |
//Property alias of upload field | |
var uploadPropAlias = String.IsNullOrEmpty(Model.MacroParameters.uploadPropAlias) ? "myUploadPropertyAlias" : Model.MacroParameters.uploadPropAlias; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
//Output an image from the media picker | |
//Property alias of mediaPicker |
NewerOlder