Experience Editor
Welcome back to Sitecore Bootcamp for Developers! In this part, we’ll extend our custom Sitecore 8.x content module we built in part 4 to use the Experience Editor allowing inline content editing.
If you are just joining us, please go back and read the introduction where you’ll also find links to each other part of the bootcamp.
Sitecore Bootcamp For Developers Part 5 Files |
Update your module to allow editing using the Experience Editor (Visual Studio)
- Update the Item Template Model
- Add Guid ID property to the interface
- This is different from the TemplateId GUID in the SitecoreType decorator.
- This ID property lets Sitecore match content to the correct module on the page.
- Add Guid ID property to the interface
- Update the Item View
- Change @Model.Field to @Html.Glass().Editable(a => a.Field, null, true)
- This will use GlassMapper to display an editing box while logged in and using the experience editor. It will render the field as text when not logged in.
- Change @Model.Field to @Html.Glass().Editable(a => a.Field, null, true)
- Build and deploy the solution
- Build -> Build SitecoreBootcamp (or Build Solution)
- Build -> Publish SitecoreBootcamp
- Refresh home page in browser
- This allows Sitecore to rebuild its caches
Editing content using the Experience Editor (Sitecore)
- Log into Sitecore
- http://sitecorebootcamp.localhost/sitecore
- Click Desktop -> Sitecore Start Menu -> Experience Editor
- Click the down arrow at the right of the Sitecore navigation bar to unhide options
- On the view tab -> Check Navigation bar
- In the navigation bar -> Click the arrow to the right of home and choose Page1 -> Click Go.
- You can also browser directly to http://sitecorebootcamp.localhost/page1
- You can also use the sites navigation (if it exists)
- You can select Publish -> Experience Editor from the Content Editor for a page
- On the home tab -> Mode -> Click Edit (if not selected)
- Moving your mouse around the page highlights modules and editable regions
- The entire module
- Setup personalization
- Delete module
- Move module
- Edit content using Content Editor
- Each individual editable field
- Inline editing
- The entire module
- Edit the title, subtitle and content
- Be sure to click the save button in the Sitecore navigation bar
- Click Home -> Mode -> Other -> Preview to view the site as a visitor would see it after publishing
- Click Home -> Publish
- Smart Publish
- Check box to publish related items
- We are editing the page. The CB1 item is related. If this box is not check, the edits to CB1 would not be published.
- Click Publish
- Open a different browser or a private tab and confirm your changes were published successfully.
- The experience editor will likely try to load on all pages after you have loaded it once until you log out or click close on the toolbar.
Adding modules to a page using the Experience Editor (Sitecore)
- Update the placeholder settings
- Open the content editor
- Click /sitecore/Layout/Placeholder Settings/content
- Allowed Controls -> Edit
- Browse to Layout/Renderings/Content Blurb
- Click the right arrow between the columns to add it to the selected list
- This allows you to add the content blurb module to a page from within the ExEditor
- Click Ok to close the dialog
- Save
- Click Publish in the Sitecore navigation bar -> Globe Icon -> Okay
- This will publish the current item
- Add module to page
- Return to /page1 in ExEditor mode
- Click Home -> New Component in the Sitecore navigation bar
- The page will display “Add here” buttons where new content can be added
- Click Add here button where you want to add the new module
- In the dialog, choose the type of content to add
- Only modules allowed in the placeholder will appear
- Click the box to open the properties dialog
- If you miss this step, you can get to properties from module region -> More -> Component Properties
- Click Datasource -> Browse
- Click Create New Content
- Name = CB2
- Parent = /sitecore/Content/Home/Page1
- Click Ok
- Edit content fields
- Click Save
- Click Home -> Publish
- Smart Publish
- Check box to publish related items
- Click Publish
Food for thought
- Modules should be “aware” that they are in the Experience Editor – that is, they should gracefully handle error conditions (ie. missing data or datasources) without throwing errors. Modules could also provide instructions or additional information about their purpose right in the EE.
- Enabling the experience editor for non-simple types (other than text) is more complex and requires “edit frames”.
Be sure to follow me through the entire month of November 2017 and follow along with each part as they become available. Thanks for reading, and be sure to leave me comments or questions, I would love to chat with you about Sitecore.
Created by: Eric Sanner, Brandon Bruno, Alan Tibbs