Skip to content

Instantly share code, notes, and snippets.

View sitefinitysteve's full-sized avatar
🏠
Working from home

Steve McNiven-Scott sitefinitysteve

🏠
Working from home
View GitHub Profile
@sitefinitysteve
sitefinitysteve / gist:9d22b8ea8e0856e5f465
Created November 11, 2014 13:22
Application_Error to handle document passthrough
protected void Application_Error()
{
//Sitefinity Logger should send to raygun now
var exception = Server.GetLastError();
//Send document requests over to login
if(exception.Message.Contains("You are not authorized to 'View document'") || exception.Message.Contains("You are not authorized to 'View image'")){
if (!ClaimsManager.GetCurrentIdentity().IsAuthenticated)
{
//If user is anonymous, send them to the login
@sitefinitysteve
sitefinitysteve / ServiceStackService
Created November 21, 2014 16:41
Sitefinity JustCode ServiceStack File Template
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Data.Linq.Dynamic;
using Telerik.Sitefinity.Services.Search;
using Telerik.Sitefinity.Utilities.TypeConverters;
using ServiceStack.Text;
@sitefinitysteve
sitefinitysteve / gist:6ec00100ec457ab1289d
Created November 25, 2014 19:04
DataIntelligenceScriptControl Const String
private const string ExecuteDataIntelligenceSubmitScriptFormat = "(function() {{\r\n var jqueryXhrModified = false;\r\n var detectjs = false;\r\n var executeDataIntelligenceScript = function() {{\r\n var source;\r\n if (!window.JSON) {{\r\n source = '{0}';\r\n }} else if (!window.jQuery) {{\r\n source = '{1}';\r\n }} else if (!jqueryXhrModified) {{\r\n source = '{2}';\r\n jqueryXhrModified = true;\r\n }} else if (!detectjs) {{\r\n source = '{3}';\r\n detectjs = true;\r\n }} else if (!window.DataIntelligenceSubmitScript) {{\r\n source = '{4}';\r\n }} else if (!window.sfDataIntell) {{\r\n source = '{5}';\r\n }} else {{\r\n return DataIntelligenceSubmitScript.load({6});\r\n }}\r\n var script = document.createElement('script');\r\n script.type = 'text/javascript';\r\n var callback = function() {{\r\n if (!this.rea
@sitefinitysteve
sitefinitysteve / SitefinityToolsFile.xml
Created January 6, 2015 17:48
Best Sitefinity RadEditor ToolsFile, use at /Sitefinity/Administration/Settings/Basic/TextEditor/
<?xml version="1.0" encoding="UTF-8"?>
<root>
<modules>
<module name="RadEditorStatistics" dockingZone="Bottom" visible="false" />
<module name="RadEditorDomInspector" visible="true" />
<module name="RadEditorNodeInspector" visible="false" />
<module name="RadEditorHtmlInspector" visible="false" />
</modules>
<tools name="MainToolbar">
<tool name="ToggleAdvancedToolbars" />
@sitefinitysteve
sitefinitysteve / UploadFile.cs
Created April 8, 2015 14:00
Sitefinity Helper to upload a file
public static Document UploadFile(string fileTitle, Stream fileStream, string fileExtension, DocumentLibrary album, Guid folderId, List<Guid> categories, List<Guid> tags, string provider = "")
{
if (album != null)
{
LibrariesManager manager = LibrariesManager.GetManager(provider);
manager.Provider.SuppressSecurityChecks = true;
string urlname = Util.UrlNameFilter(fileTitle);
Document document = null;
//Check for document
@sitefinitysteve
sitefinitysteve / RunWithUserRegion.cs
Created June 9, 2015 18:20
Responsible for running set of operations with specific user
using System;
using System.Linq;
using System.Security.Principal;
using System.Threading;
using System.Web;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;
using Telerik.Sitefinity.Services;
namespace Telerik.Sitefinity.TestUtilities.CommonOperations.Permissions.Api
@sitefinitysteve
sitefinitysteve / SimpleViewControlReference
Created August 24, 2015 19:42
JustCode template to reference a control in a Sitefinity .ascx simpleview template. I usually bind it to "sfv".
protected virtual $2$ $1$
{
get{
return this.Container.GetControl<$2$>("$1$", true);
}
}
@sitefinitysteve
sitefinitysteve / Sitefinity Rename Forms Database Table
Created June 4, 2012 13:51
Sitefinity Rename Forms Database Table
-- the old name of the form
declare @oldName nvarchar(30) = 'sf_table_name';
-- the new name of the form
declare @newName nvarchar(30) = 'sf_table_name';
-- rename the table with form entries
exec sp_rename @oldName, @newName;
-- change the form name in the forms description
update [sf_form_description]
@sitefinitysteve
sitefinitysteve / DetectIndexRenderingMVCFeather.cshtml
Created October 14, 2015 15:10
Detect when your view is being indexed
@using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers;
@if (ViewContext.Controller.GetIndexRenderMode() == Telerik.Sitefinity.Web.UI.IndexRenderModes.Normal)
{
<div>FROM LAYOUT</div>
}
@sitefinitysteve
sitefinitysteve / Samples.aspx
Last active December 19, 2015 04:38
Sitefinity Template Layout Helpers. Use these in a RadListView to generate you dynamic layout wrappers around your content.
<!-- Regular Sample -->
<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
<LayoutTemplate>
<div class="sf_cols">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class='<%# Util.Out(Container) %>'>
<div class='<%# Util.In(Container) %>'>