This file contains hidden or 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 Sitecore.Collections; | |
using Sitecore.Diagnostics; | |
using Sitecore.Reflection; | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Collections.Specialized; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; |
This file contains hidden or 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
var values = WebUtil.ParseQueryString("print=1&target=me&group=first"); | |
var s0 = values["print"]; // "1"; | |
var s1 = values["target"]; // "me"; | |
var s2 = values["group"]; // "first"; | |
var s3 = values["non-existing"]; // null; |
This file contains hidden or 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
var url1 = WebUtil.AddQueryString("http://www.mysite.net", "print", "1"); | |
// Result: "http://www.mysite.net?print=1" | |
var url2 = WebUtil.AddQueryString("http://www.mysite.net", "print", "1", "lg", "print"); | |
// Result: "http://www.mysite.net?print=1&lg=print" |
This file contains hidden or 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 HtmlAgilityPack; | |
using Sitecore.Caching; | |
using Sitecore.Collections; | |
using Sitecore.Configuration; | |
using Sitecore.Data.Fields; | |
using Sitecore.Data.Items; | |
using Sitecore.Diagnostics; | |
using Sitecore.IO; | |
using Sitecore.Layouts; | |
using Sitecore.Links; |
This file contains hidden or 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
// Returns QS or Empty String | |
var qsWithKey = WebUtil.GetQueryString("key"); | |
// Returns QS or Default Value | |
var qsWithKeyAndDefaultValue = WebUtil.GetQueryString("key", "master"); | |
// Returns Encoded QS or Empty String | |
var safeQs = WebUtil.GetSafeQueryString("key"); |
This file contains hidden or 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 EnforceItemName | |
{ | |
protected void OnItemSaved(object sender, EventArgs args) | |
{ | |
var currentItem = Sitecore.Events.SitecoreEventArgs.GetItem(args, 0); | |
if (currentItem != null && currentItem.Name.Contains(" ") && (currentItem.Paths.IsContentItem || currentItem.Paths.IsMediaItem)) | |
{ | |
currentItem.Editing.BeginEdit(); |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
var wildItemName = "<strong class=\"color-me-red\">Name of a Product<sup>™</sup> Version 1!!!!!</strong>"; | |
Console.WriteLine(ToValidItemName(wildItemName)); | |
Console.WriteLine(ToValidItemName(wildItemName, true, true)); | |
Console.ReadKey(); | |
} | |
public static string ToValidItemName(string str, bool toLower = false, bool replaceSpacesWithDashes = false) |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
var wildItemName = "<strong>Name of a Product<sup>™</sup> Version 1</strong>"; | |
var notEntirelyFixed = ItemUtil.ProposeValidItemName(wildItemName); | |
Console.WriteLine(notEntirelyFixed); | |
Console.ReadKey(); | |
} | |
// Result: strongName of a Productsupsup Version 1strong |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
var wildItemName = "<strong>Name of a Product<sup>™</sup>Version 1</strong>"; | |
var notEntirelyFixed = | |
Regex.Replace(wildItemName, @"[^0-9a-zA-Z]+", " ").Trim(); | |
Console.WriteLine(notEntirelyFixed); | |
Console.ReadKey(); | |
// Result: strong Name of a Product sup sup Version 1 strong | |
} |
This file contains hidden or 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
namespace EETK.Foundation.Toolkit.Rules.Actions | |
{ | |
public class DisplayAdditionalItemInformation<T> : RuleAction<T> where T : CustomSectionsRuleContext | |
{ | |
public override void Apply(T ruleContext) | |
{ | |
var editorSection = ruleContext.EditorSection.FirstOrDefault(x => x.DisplayAdditionalItemInformation) ?? new EditorSection(); | |
editorSection.Title = Translate.Text("Additional Item Information"); | |
editorSection.DisplayAdditionalItemInformation = true; |
NewerOlder