The 2016 Sitecore Symposium that took place September 14-16 in New Orleans was a true mix of “work” and play. One of my favorite things about symposiums is the quality of the speakers and the content that they are able to deliver in such a short period of time.
As usual, we had Michael Seifert and his partner in crime Darren Guarnaccia put on an awesome opening keynote demonstrating some of the new things Sitecore has to offer. Two features in particular really caught my eye: the Sitecore Experience Accelerator (SXA) and Sitecore Commerce.
Here are the aspects of each feature that I am most excited about.
Add Help Text to Field in Sitecore Page Editor
It is very common for content authors to need a little extra assistance when entering content through the page editor. For example, they may be uploading an image and need to know what the recommended dimensions are. Instead of having to reference an old email from the developers who built the site or dig up an old conversation in Basecamp, you can now provide this information to them right in the page editor. Below is an example of what this looks like.
Hours of Operation Custom Field Type
Frequently when building Sitecore sites, the need has come up for the content author to be able to enter the hours of operation for their business. Unfortunately there is no built-in field type in Sitecore and nothing on the Sitecore Marketplace. With the help of two of my colleagues, Aaron Ladage and Patrick Delancy, we created a custom hours of operation field type. Our type allows content authors to easily enter opening and closing times for each day of the week. The value is stored as XML and can be easily parsed not only to display for website visitors, but also to add the proper microdata and boost the website’s SEO.
Using Sitecore Configuration Factory For Basic Dependency Injection
Dependency injection in .NET has become fairly commonplace and there are many popular frameworks out there to do so. If you’re embracing the philosophy of building generic re-usable pieces of functionality, you may not want to tie yourself down to one particular technology. Fortunately Sitecore provides a solution that will allow you to easily use different IoC frameworks between projects. This post will describe how to utilize the Sitecore configuration factory for basic dependency injection.
Extending Web Forms for Marketers Form Report Export
Web Forms for Marketers provides a great feature called form reports which gives you access to every web forms form submission. Sitecore provides you with two formats for exporting these records. You can export them to an Excel document (.xls) or to an XML document (.xml). However, your users might want to export the records to other formats. This post will describe how to add your own custom export button using a format of your choosing.
Extending Sitecore Workflow Email Action
If you decompile the Sitecore Kernel, you will see three variables that you can use in your email action out of the box:
- $itemPath$
- $itemLanguage$
- $itemVersion$
However, for many people the need arises to have use their own. This post describes how to do so.
How To Create Sitecore Scheduled Task
To create a scheduled task in Sitecore, first you must create the .NET class that will contain the logic that you wish to execute. In the example below I’m simply logging a message whenever the task is run.
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 void Execute(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule) | |
{ | |
Sitecore.Diagnostics.Log.Info("My Sitecore scheduled task is being run!", this); | |
} |
Your method must accept three arguments.
- An array of items that can be specified in a later step when you define the command’s schedule.
- The Sitecore task CommandItem
- The Sitecore task ScheduleItem
Sitecore.Links.LinkManager and the context
Brian Pedersen's Sitecore and .NET Blog
A new feature in Sitecore 6 is the LinkManager. Previously, in Sitecore 5, in order to get a friendly url (an URL with the .aspx extension) you would write the following:
In Sitecore 6, the GetFriendlyUrl() is deprecated. Instead we are encouraged to use the Sitecore.Links.LinkManager. The same piece of code would look like this:
The LinkManager provides us with a lot of features that the GetFriendlyUrl() did not. But it also introduces some pitfalls. The LinkManager runs in a context that is not necessarily the same as the Item you are getting the link from, nor the context you wish to run in. Let me explain. Imagine you write a Sitecore shell extension that returns the path to an item. The Item is grabbed from the web database:
The path to the item is “/sitecore/content/home”.
Now, lets get the item’s URL:
This returns the item URL for…
View original post 181 more words
Fixing System.InvalidOperationException: field When Trying To Open Rendering Parameters in Sitecore
If you’re getting a nasty error that looks like this
when trying to open a rendering that you recently created rendering parameters for, this could fix your problem!
Web Forms For Marketers MVC – Terms of Agreement Custom Field Type
Recently the Web Forms For Marketers Module for Sitecore has released support for MVC. With that, lets go over how to create a custom type to be used on your MVC form.
First you’ll need to add a new type under the Field Types folder.
Now in your Visual Studio project, create a new class TermsAgreementField.cs that inherits from CheckBoxField.
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 Sitecore.Data.Items; | |
using Sitecore.Forms.Mvc.Attributes; | |
using Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders; | |
using Sitecore.Forms.Mvc.Models.Fields; | |
using Sitecore.Forms.Mvc.Validators; | |
namespace MyProject.Integration.Wfm | |
{ | |
public class TermsAgreementField : CheckBoxField | |
{ | |
public string TermsLabel { get; set; } | |
[DynamicRequired("IsRequired", ErrorMessage = "The {0} field is required.")] | |
[PropertyBinder(typeof(CheckboxFieldValueBinder))] | |
public override object Value { get; set; } | |
public override bool IsRequired | |
{ | |
get { return true; } | |
} | |
public TermsAgreementField(Item item) : base(item) {} | |
} | |
} |
Note here that I have made this a required field by making IsRequired always return true.