Skip to content

Instantly share code, notes, and snippets.

@hishaamn
hishaamn / z.Logging.config
Created January 23, 2017 16:44
Sitecore Log4net
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<log4net>
<appender name="ADONetAppender_SqlServer" type="log4net.Appender.ADONetAppender, Sitecore.Logging">
<bufferSize value="1" />
<param name="ConnectionType" value="System.Data.SqlClient.SqlConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<param name="ConnectionString" value="user id=[userName];password=[password];Data Source=[ServerName];Database=Sitecore.Logging" />
<param name="CommandText" value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
<param name="Parameter">
@hishaamn
hishaamn / sc.connectionstring.xml
Last active February 4, 2017 16:27
Publishing Service Connection String
<Settings>
<Sitecore>
<Publishing>
<ConnectionStrings>
<Master>user id={userId};password={Password};Data Source={Datasource};Database=SitecoreExperimentalLab_Master;MultipleActiveResultSets=True;</Master>
<Web>user id={userId};password={Password};Data Source={Datasource};Database=SitecoreExperimentalLab_Web;MultipleActiveResultSets=True;</Web>
<Core>user id={userId};password={Password};Data Source={Datasource};Database=SitecoreExperimentalLab_Core;MultipleActiveResultSets=True;</Core>
</ConnectionStrings>
</Publishing>
</Sitecore>
@hishaamn
hishaamn / z.PublishingService.config
Last active February 5, 2017 09:33
Connection between Host and Module
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<!-- Example: <setting name="PublishingServiceUrlRoot">http://local.publishingservice.com/</setting> -->
<setting name="PublishingServiceUrlRoot">http://{your site url here}/</setting>
</settings>
</sitecore>
</configuration>
@hishaamn
hishaamn / gist:8914f7e4db44596c2ca5cdd0270e5402
Created March 5, 2017 16:34
Sitecore Powershell Script
$templateItem = Get-Item -Path "master:\templates"
$props = @{
Parameters = @(
@{ Name = "userInput"; Title = "User Input"; Tab = "General" },
@{ Name = "templateItem"; Title = "Start Item"; Root = "/sitecore/Templates/"; Tab = "General" }
)
Title = "Powershell Demo"
OkButtonName = "Proceed"
CancelButtonName = "Abort"
@hishaamn
hishaamn / gist:8b72f553c4ded1779697a01ce35d9814
Created March 5, 2017 16:55
Method call from powershell
public class Demo
{
public bool GetResponse(string userInput, Item templateItem)
{
//Perform the different logic here
...
...
return response
}
<sitecore>
<loggedin>
<processor mode="on" type="YourNamespace.YourClass, YourAssembly" />
</loggedin>
</sitecore>
public class EnforceEntireTree
{
public void Process(LoggedInArgs args)
{
User user = User.FromName(args.Username, true);
Assert.IsNotNull(user, "user");
string key = "/" + user.Name + "/UserOptions.View.ShowEntireTree";
user.Profile.Initialize(user.Name, true);
user.Profile[key] = "true";
@hishaamn
hishaamn / function Site Creator
Created April 28, 2017 17:14
Sitecore SPEAK with Powershell
(function (Speak) {
Speak.pageCode(["sitecore", "jquery", "arcwaveUtils"], function (sitecore, $, Utils) {
return {
initialized: function () {
// your code for initialized
},
triggerSiteCreator: function () {
[HttpGet]
public ActionResult SiteCreator()
{
var shellSite = SiteContext.GetSite("shell");
using (new SiteContextSwitcher(shellSite))
{
var urlString = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
urlString.Append("scriptId", "My SPE Script Id");
urlString.Append("scriptDb", "master");
@hishaamn
hishaamn / ScriptSession.ps1
Created May 10, 2017 18:48
SPE - Script Session
$scriptPath = "master:\system\Modules\PowerShell\Script Library\Experimental\Item Delete"
Start-ScriptSession -Path $scriptPath -Interactive -AutoDispose