Experience Editor Exposé – Rapid Item Entry

Content entry of multiple items in Experience Editor

Exposing Experience Editor

The Experience Editor is a Sitecore integrated tool that exposes fields on the current page for editing, WYSIWYG style.  In MVC views, if you take advantage of the HTML helpers provided by Sitecore to render fields or use Glass Mapper’s Editable helper, the fields from the current context item are magically editable in this Editor.

This blog series intends to reveal some common scenarios that are not natively built in and require a combination of configuration and perhaps some coding.

A common scenario that I’ve seen is the content editor’s desire to rapidly add one item after another in Experience Editor.  There is an “Insert Page” option in the XE ribbon, however, this is to create a item as a child of the existing item.

Inserts a new child item

To do repeatedly enter sibling items in XE without any configuration, the user does the following:

  • create a new item in the content editor
  • go to the Publish->Experience Editor ribbon command
  • add content to new item
  • save
  • close XE
  • …repeat …

(NOTE:  The user could also create a child item with the “Insert page” option, followed by the “Move page” option.  This is clunky as well).

Here is an alternative.  Create a ‘window’ to the parent item on the existing page and then expose the “New Item” functionality in the Field editor buttons.

In the example below, we have a parent folder called “Articles” with either one- or two-column articles as children.  We’ve added an “Button Name” field to the folder to support a button name.

Articles folder has Insert Options of “Article One Column” and “Article Two Column”

Let’s add an Edit Frame and expose the ability to insert a child article under the Articles folder while viewing a child article in Experience Editor.

In the main article’s MVC view and CORE database, do the following:

  1. Add a reference to the Sitecore.Context.Item.Parent (be sure to add in any null checks, etc)
    var ParentModel = SitecoreContext.Cast<Article_Folder>(Model.Item.Parent);
  2. Add a new Edit Frame Button folder and Insert WebEdit Button in the Core database at:  /sitecore/content/Applications/WebEdit/Edit Frame Buttons
    edit frame example.png
  3. Add an EditFrame inside the View.  This references the path of the Edit Frame Folder in the Core database. The Button_Name also becomes editable if needed.
var path="/sitecore/content/Applications/WebEdit/Edit Frame Buttons/AddArticlePage"
using (BeginEditFrame(path))
 <button>@Editable(ParentModel, x=>x.Button_Name)</button> 



After saving the current article, use this new button’s “insert item” functionality to add a sibling article.



Sitecore: Using PowerShell Extensions to create new items in Sitecore from a CSV

So you wanna import data into Sitecore and the source you have is an Excel spreadsheet?

You can convert it to CSV and import with PowerShell Extensions.  The script below imports a series of items from a CSV. Based on the template, it decides the Sitecore content path (blog or article).  It assumes that the CSV has columns with the following headers:

  • ItemName  – does not support invalid characters (see your Sitecore.config)
  • PageTitle – mapped to a Page Title field on the template
  • Templates – a Sitecore path to each row’s template
  • CreatedBy

Basic PowerShell Script

$global:BlogPath = "/sitecore/content/SampleSite/Home/Blogs"
$global:ArticlePath = "/sitecore/content/SampleSite/Home/Articles"

$InputcsvFile = Show-Input "Input file path"
$csv = Import-CSV $InputcsvFile -delimiter "," 

$bulk = New-Object "Sitecore.Data.BulkUpdateContext"

 foreach($record in $csv)
   $path = $global:BlogPath
   if ($record.Templates -like '*Article*') {
    $path = $global:ArticlePath
   $item = New-Item -Path $path -Name $record.ItemName -ItemType $record.Templates
     $item["__Display name"] = $record.ItemName
     $item["Page Title"] = $record.PageTitle
     #add other mappings ...
     $item["__Created by"] = $record.CreatedBy
 Write-Host "Item created: " $record.ItemName

Data Massaging – using VB Macro

The data from the source system isn’t necessarily going to be ready to import. Because I was running the import multiple times, I wrote a data massaging VM Macro to do the following:

  • Convert the source Page Title to a valid Item Name (created a new column)
  • Convert tag words to guids. Since I had to import tags (words), I imported the guids for the tags to a separate worksheet and used VLOOKUP.
  • Add template path. The spreadsheet indicated whether each row was an article or blog; I created a column for the template path for each and used VLOOKUP from another worksheet

This macro below may be helpful.

'sheetName = worksheet where guids are located
'originalCol = column that contains a pipe-delimited list of tags as words
'newCol = destination for pipe-delimited guids
'importSheet = output worksheet (to CSV)
'maxRow = total number of rows in output worksheet

Sub ReplaceMetaTags(sheetName, originalCol, newCol, importSheet, maxRow)
 'get range of meta tag sheet
 Dim sht As Worksheet
 Set sht = Sheets(sheetName)
 Range(Selection, Selection.End(xlToRight)).Select
 Range(Selection, Selection.End(xlDown)).Select
 Dim lastTagRow As Long
 lastTagRow = Selection.Rows.Count
 'switch back to importSheet
 'create new column for guids
 Range(originalCol & "1", originalCol & maxRow).Select
 Application.CutCopyMode = False
 Selection.Insert Shift:=xlToRight
 Range(newCol & "2", newCol & maxRow).Select
 Dim fRange As Range
 Set fRange = Selection
 Dim fcellValue As String
 Dim newCellValue As String
 For Each rngCell In fRange
 fcellValue = rngCell.Text
 If fcellValue = "" Then
 rngCell.Value = ""
 ElseIf InStr(1, fcellValue, "|") Then
 Dim arr As Variant
 arr = Split(fcellValue, "|")
 newCellValue = ""
 For i = 0 To UBound(arr)
 topicVal = Application.VLookup(arr(i), sht.Range("A2:B" & lastTagRow), 2, False)
 If Len(newCellValue) > 0 Then
 newCellValue = newCellValue + "|" + topicVal
 newCellValue = topicVal
 End If
 Next i
 rngCell.Value = newCellValue
 Else 'single value
 rngCell.Value = Application.VLookup(fcellValue, sht.Range("A2:B" & lastTagRow), 2, False)
 End If
 Next rngCell

End Sub

Lessons Learned: xDB Cloud Edition setup helpful hints

While installing xDB Cloud Edition for a client, it’s important to know about the two distinct versions … 1.0 and 2.0.  (Deployments of new sets in xDB Cloud 1.0 are not available).

Ensure that you know the correct edition.  If you make the mistake that I did (installing 1.0 dlls and configs when the client purchased 2.0), you’ll encounter some errors.

First of all, the configuration files in the /Include/xDB Cloud folder are named the same (for 1.0 and 2.0) but there are major differences in them.

For instance, with 1.0, you receive configuration information from Sitecore support and enter it in the configuration information into the Sitecore.Cloud.Xdb.config.

Could not find configuration node: contentSearch/retryPolicy
Exception: System.InvalidOperationException
Message: Could not find configuration node: contentSearch/retryPolicy
For xDB 2.0, the NonProd deployment type is not supported. For more information, see the article: