Vous êtes sur la page 1sur 384

Website Development for

.NET Developers

8.0.0.3 www.sitecore.net/training
Let’s Begin!
HELLO
My name is
Welcome Introductions
___

Materials Cell phones

Breaks Facilities

8.0.0.1 www.sitecore.net/training
Module 1
Sitecore Overview

Course Overview & Agenda


What Is Sitecore?
Sitecore from an Author’s Perspective
Sitecore from a Developer’s Perspective

8.0.0.1 www.sitecore.net/training
Topic 1.1
Course Overview & Agenda

By the end of this topic you will be able to:

Describe the objectives of this course

8.0.0.1 www.sitecore.net/training
Objectives for This Course
By the end of this course, you will be able to:
Define data and assemble presentation components
Use common API features
Configure and build for the Experience Editor
Deal with complex sites and large volumes of data
Extend Sitecore’s core functionality
Use recommended practices around installation,
environments, scaling and optimization

Find help and modules

8.0.0.3 www.sitecore.net/training
Course Format

10 modules 1 2 3 4 5 6 7 8 9 10

Topic 1 Topic 2 Topic 3 Topic x


Each module has several topics

Demos

Exercise – Labs

Review – Questions

Extend

8.0.0.3 www.sitecore.net/training
Module Overviews
Module 1 Sitecore Overview Module 6 Real World Solutions
Module 2 Defining Data Module 7 Configuring the Experience Editor
Module 3 Presentation Module 8 Dealing with Your Data
Module 4 Sitecore API Module 9 Beyond Developer Environment
Module 5 Advanced Presentation Concepts Module 10 Analytics

Module 11 Bonus Topics

Exam and Certification


Exam with 40 questions
Online, open book

version 8.0.0.1 www.sitecore.net/training


Prerequisites
Introductory video
Browser Configuration set-up steps
Can do the following unaided:
• Use LINQ statements and Lambda expressions
• Use C# Indexers
• Create and use User Controls
• Add References, use Namespaces and create Public Properties
• Add and use data-bound controls like Repeaters
• Add and read values in the web.config through code
• Debug code with Visual Studio

8.0.0.3 www.sitecore.net/training
Topic 1.2
What Is Sitecore?

By the end of this topic you will be able to:

List key features of the Sitecore Experience Platform (XP)


Describe a typical scenario for a visitor
Find more information
Contact support

8.0.0.1 www.sitecore.net/training
Sitecore Is an Experience Platform
Sitecore combines content management with a marketing
platform
• Design and populate a website
• Tailor the experience to individual visitors

What does Sitecore offer marketers?


• Inline page design and population
• Personalization and multivariate testing
• Cross-channel communication
• Integration with external tools and databases
• Rich reporting on individual visitors

8.0.0.3 www.sitecore.net/training
Cross-Channel Communication
Offering a consistent, individual experience regardless of how visitors
interact with your content

Mobile Search engine


offers marketing

Online and
Social media
offline
engagement
advertising
campaigns

Email Direct sales


offers and call center

8.0.0.3 www.sitecore.net/training
A Typical Scenario
A Land on site, 4 Sign up for 5
3 Receive e-mail –
contact form callback
personalized based “Visit Facebook
on IP and how you while you wait!”
found the site

Like Facebook 6
2 Follow
page, click link to
campaign
site – personalized
link
10% off offer

1 Google Sales rep 7


“Cycling Can see that you
Holidays” triggered that offer

8.0.0.3 www.sitecore.net/training
The Developer’s Role
Who are you?
• Professional ASP.NET developers
• Passionate about supporting business goals
What are your responsibilities?
• Build and scale according to recommended practices
• Support Sitecore’s marketing and analytics features
• Build for the Experience Editor
• “Don’t fight the framework!”

This course will get you there!

8.0.0.3 www.sitecore.net/training
What’s in It for You?
A world leader in customer Clients include:
experience management ASOS, Nestle, Brother, Cadbury, Dyson
• We deliver highly relevant content and easyJet, Canon, Heineken, Kia Motors
personalized digital experiences Play.com, Virgin Active, Thomas Cook
• You will be sought after for your
Sitecore skills

MVP program
• Technical previews, MVP summit,
closed product feedback circuit

Active community
• SDN, Twitter, Stack Overflow, blogging

8.0.0.3 www.sitecore.net/training
Where Can I Find More Information?
Knowledgebase Marketplace Developer Network
(support articles) (modules) (forum, downloads)

kb.sitecore.net marketplace.sitecore.net sdn.sitecore.net

Documentation
• https://doc.sitecore.net/
• https://sitecore-community.github.io/docs/
Modules
• Email Experience Manager
• Web Forms for Marketers
• Social Connected
Modules Compatibility Table: https://kb.sitecore.net/articles/541788
8.0.0.3 www.sitecore.net/training
Sitecore XP 8 Resources

Visit dev.sitecore.net
doc.sitecore.net

8.0.0.3 www.sitecore.net/training
How Do I Contact Support?
http://support.sitecore.net
• Before filing a ticket:
o Try reproducing the issue on a clean installation
o Look at log files using log analyzer
https://marketplace.sitecore.net/en/Modules/Sitecore_Log_Analyzer.aspx
o Compare <yoursite>/sitecore/admin/ShowConfig.aspx to stock web.config
o Search marketplace if asking for code examples

• One problem per issue


• Timestamp your responses
• Attach
o Relevant configuration files
o Recent log files, screenshots of UI errors and related files
o Exceptions as plain text documents
• Use the Support Package Generator module
https://marketplace.sitecore.net/Modules/Sitecore_Support_Package_Generator.aspx

Public FTP (10MB+ files): http://sdn.sitecore.net/Support/Sitecore%20Public%20FTP.aspx


HelpDesk Best Practices: http://sdn.sitecore.net/Support/Helpdesk%20Best%20Practices.aspx
8.0.0.3 www.sitecore.net/training
Task – Sign Up on SDN
• Visit http://sdn.sitecore.net/
• If you are unable to log in successfully...
o Register a new account
o Specify the name you want to appear on your course certificate.
• SDN account needed to take the exam

8.0.0.3 www.sitecore.net/training
Review – What Is Sitecore?
Q Name two key components that Q What should you do before you
make up Sitecore XP:
contact support?
 Experience CMS and marketing
platform  Refer to HelpDesk best practices
Q Name some sites that you can refer Q What are your responsibilities as
to for more information and
module downloads. a developer?
 SDN:  Build according to recommended
http://sdn.Sitecore.net practices
 Knowledge Base:
https://kb.Sitecore.net
 Marketplace:
https://marketplace.Sitecore.net
 Sitecore XP 8:
https://dev.Sitecore.net
 Sitecore XP 8 Documents:
https://doc.Sitecore.net

8.0.0.3 www.sitecore.net/training
Topic 1.3
Sitecore from an Author’s
Perspective
By the end of this topic you will be able to:

Name interfaces that Sitecore business users have access to


Determine which interface is suitable for which task
State how Sitecore data is represented to authors
Name the process by which content is pushed to a live environment

8.0.0.1 www.sitecore.net/training
Your New Job Flow with Sitecore

Architects
Storyboard BE Developer

FE Developer

Authors
Live Site

QA
Marketing
Live Site Marketing

Print Media (PXM)

8.0.0.3 www.sitecore.net/training
Sitecore as a Web Experience Manager (WXM)

8.0.0.3 www.sitecore.net/training
Demo 1.3 – Sitecore Interfaces
In this demo:
• Use the Experience Editor – navigating, editing and designing
• Use the Desktop
• Use the Content Editor
• Publish content

http://basicsitecore/
To log in, append /sitecore to your URL:

Click Icon to select an editing


interface after successful login
8.0.0.3 www.sitecore.net/training
Items and the Content Tree Homepage item

Items Holiday items


• Everything in Sitecore is an item
• An item is a unit of content, not a page
• Items are not files
• Each item has a GUID (Global Unique IDentifier)

Content Tree Register item


• Items are represented in a hierarchical structure
called the Content tree
• Sitecore interfaces display all or part of the Content
tree
URLs
• Some items are addressable via a URL
• URL maps to position in tree

8.0.0.3 www.sitecore.net/training
Publishing and the Sitecore Databases
• Sitecore Publishes items from the Master to the Web database

Publishing synchronizes the


Web and Master database
with updated or deleted items
Master Database Web Database
Work in Progress Live
8.0.0.3 www.sitecore.net/training
Review - Sitecore from an Author’s Perspective

Q Name three Sitecore interfaces: Q Name the process by which


items are synchronized between
 Desktop, Content Editor, Experience the master and web database:
Editor
 Publishing
Q Everything in Sitecore is an…
Q Which Experience Editor mode
 Item would you use to add a new
component?
Q An item is not a…
 Designing mode
 File
Q Which Experience Editor mode
Q An item’s URL is determined by… would you use to add an image
 Its position in the Content tree or edit text?
 Editing mode

8.0.0.3 www.sitecore.net/training
Topic 1.4
Sitecore from a Developer’s
Perspective
By the end of this topic you will be able to:

Explain what gets installed on your computer when you install Sitecore
Name three Sitecore databases
Name four foundation features that Sitecore provides out of the box
Draw out the minimum requirements for a production environment

8.0.0.1 www.sitecore.net/training
Sitecore Architecture
Sitecore is an ASP.NET application
Applications

Base Implementation

Sitecore
API Layer
Data

Sitecore is a framework for:


Content versioning, media library, design/editing interfaces, language versioning,
presentation versioning, search API, adaptive design via devices, rich API, hierarchical
data storage and much more!

8.0.0.3 www.sitecore.net/training
Requirements for Sitecore
Current Requirements
• ASP.NET 4.5
• SQL 2008 R2 SP1 or better
• IIS Integrated Mode
• MVC 5.1 (for SPEAK UI)
• MongoDB (if using xDB/Analytics)

Sitecore CMS Compatibility Table


https://kb.sitecore.net/articles/087164

MVC Compatibility Table


https://kb.sitecore.net/articles/522918
Modules Compatibility Table
https://kb.sitecore.net/articles/541788

8.0.0.3 www.sitecore.net/training
Separation of Concerns
Authors and developers have separate responsibilities
Authors… Developers…
• Mange content and presentation using • Define data structure and presentation
your custom implementation of Sitecore components for authors

Sitecore Rocks
Visual Studio Plugin

Core Web Master

Pages are dynamically assembled on demand

8.0.0.3 www.sitecore.net/training
How Sitecore Handles a Request
Browser IIS Sitecore

Requests URL
Passes request

Run HttpRequestBegin pipeline


Map request to a
content item

Page dynamically
assembled*
Stream response back

Browser IIS Sitecore

*More in Module 3
8.0.0.3 www.sitecore.net/training
What Gets Installed?
Databases
• Master – authoring database, work in progress Core Master Web
• Web – published, live content
• Core – settings and membership
• xDB – MongoDB NoSQL collection. New starting with 7.5! xDB Reporting
• Reporting – replaces Analytics DB previous to version 7.5

File system
• Website – Web root of your Sitecore application
• Database – database files
• Data – license, Sitecore logs, packages, indexes

8.0.0.3 www.sitecore.net/training
Installation Scenarios – Recommended Minimum
Content Database Content
Management server Delivery
server server

Live environment
Authoring environment
No access to Sitecore
Previewing capabilities Master Web client (*/sitecore)
• Access to master • Access to web
• Access to web • Access to core
• Access to core
Core

Sitecore 8 – Experience Database (xDB) and Experience Marketing

8.0.0.3 www.sitecore.net/training
Review – Sitecore from a Developer’s
Perspective
Q When a request comes in, Q Name some foundation features
Sitecore… that Sitecore provides out of the
 Maps a URL to an item in the content box.
tree and dynamically assembles  Content versioning, multi-language
presentation support, devices (adaptive design)
support
Q Name the three databases that
are installed by default. Q What is the name of the digital
 Master, web, core marketing management part of
the Experience Platform that
collects and aggregates contact
information?
 xDB (or Experience Database)

8.0.0.3 www.sitecore.net/training
Module 2
Defining Data

Creating Data Templates


Data Template Inheritance
Standard Values
Insert Options
Summary and Optional Lab

8.0.0.3 www.sitecore.net/training
Creating Data Templates
Topic 2.1

By the end of this topic you will be able to:

Create a data template

8.0.0.3 www.sitecore.net/training
Items, Fields and Data Templates
An item Field
• Is a unit of data in Sitecore Section
• Has fields organized into field sections
Data templates Fields

• Fundamental building block in Sitecore


• Define a type of item
• Determine what field sections, field
types and field names compose an item
• Field types determine the editor control
used in the tools, for example: Image
fields, Rich Text fields

A data template defines


field sections and fields
8.0.0.3 www.sitecore.net/training
Deciding the Data Structure Architecture
Architecture inferred from designs, wireframes and static HTML
• Project should start with focus on designing your data structure (like SQL schema)
• Examine the content on the page and across all pages
• Is the structure of content repeated on multiple pages?
• Recommended Practice: Use a Sitecore Partner for your first project
What data architecture can you infer from the designs below?

8.0.0.3 www.sitecore.net/training
Building Data Templates
Start by building data templates
• After your thorough data analysis, begin by building
base templates
• Include Fields and Field Sections that can be reused
• In our project, Content Base will become the base
template for our future templates
Content Base
• The easiest way to create data templates is using
Sitecore Rocks Heading
Main Content
Main Image

8.0.0.3 www.sitecore.net/training
Field Type Determines…
• Editing controls used in the Sitecore Tools

• Raw value stored in the database

(more about field types in Module 4)

8.0.0.3 www.sitecore.net/training
Field Source Folder with images
in Content Tree

Fields that take extra configuration:


• Image – parent item of selectable images
• Rich Text - toolbar button configuration
• MultiList - parent item of selectable items
• Some other field types can take queries or parameters
o More about field types which use a field source in Module 4 Folder of
selectable images

Note: An inherited field source cannot be overridden

8.0.0.3 www.sitecore.net/training
This Course Uses Sitecore Rocks Extensively
A free plug-in that integrates Sitecore and Visual Studio IDE
• Provides access to Sitecore Content Tree
• Integrates with .NET component development
• Authors use Sitecore Client Tools vs. Sitecore Rocks

8.0.0.3 www.sitecore.net/training
Demo 2.1 – Creating Data Templates

Demo objectives
• Create a data template and name it Content Base
• Add three fields to the template: Heading, Main Image and Main Content

Use Commandy!
CTRL + SHIFT+ SPACE

• Different results occur depending on


what you have selected
• All menus in Sitecore Rocks are context
specific

(You will be performing these tasks in the upcoming labs.)

8.0.0.3 www.sitecore.net/training
Exercise 2.1 – Create Data Templates

Lab 2.1.A Create a data template and name it Content Base

8.0.0.3 www.sitecore.net/training
Review – Defining Data Structure
Q An item’s type is determined by Q What do you need to specify
the ______ used to create it. when creating a new field?
 Data template  Field name and type

Q What is an item composed of? Q Some examples of field types


 Field sections and fields are…
 Single-Line Text, Rich Text, Image,
Date

8.0.0.3 www.sitecore.net/training
Topic 2.2
Data Template Inheritance

By the end of this topic you will be able to:

Configure a data template to inherit from selected base templates


Describe the benefits of data template inheritance
Name the data template that is the base template for all data templates

8.0.0.3 www.sitecore.net/training
Challenges with Repeated Fields
Important issues:
• There is no one true source for these fields
• Changes to field names and types have to be applied on every single data template

Holidays Section Trip Bicycle

Heading Heading Heading


Main Content Main Content Main Content
Main Image Main Image Main Image
Price per person Type
Start date Suitability

8.0.0.3 www.sitecore.net/training
Data Template Inheritance
Inheritance …
Standard
• Merges fields from all System fields
Template
inherited data templates
• All data templates inherit
from Standard Template Heading
Main Content Content
o contains fields that define Main Image Base
system properties
• Modifying the Content Base
template will affect all the Holidays
items immediately Trip Bicycle
Section

Price per Person Type


Start Date Suitability

8.0.0.3 www.sitecore.net/training
Resulting Inherited Structure
Holidays Section Trip Bicycle
Heading* Heading* Heading*
Main Content* Main Content* Main Content*
Main Image* Main Image* Main Image*
Price per person Type
Start date Suitability
*Fields inherited from Content Base
After inheriting from the base template, Content Base
• Every data template receives fields defined in Content Base
Warning:
• Field names should be unique, but field sections with the same name will merge
• Avoid circular data template inheritance - never inherit indirectly from itself
• Get data template inheritance right! Refactoring may cause a loss of field values
8.0.0.3 www.sitecore.net/training
Demo 2.2 – Assign and View Data Template
Inheritance
Demo objectives
• Create a Holidays Section data template
• Set the Holidays Section data template icon
• Change Holidays Section data template to inherit from Content Base
• Create a Family Holidays item based on the Holidays Section data template
• Create a Trip data template and change it to inherit from Content Base
• Create a Cycle the Cotswolds item under the Family Holidays item, using the
Trip data template
• View the list of data templates that Cycle the Cotswolds inherits

8.0.0.3 www.sitecore.net/training
Exercise 2.2 – Template Inheritance

Lab 2.2.A Create a data template named Holidays Section and data
template named Trip

Lab 2.2.B Configure Holidays Section and Trip to inherit from


Content Base

Lab 2.2.C Create content items using the Holiday Section and Trip
data templates

8.0.0.3 www.sitecore.net/training
Creating Items Review
1

2
Item uses data template icon –
easy to distinguish types

Expand Quick Info to see


Add multiple items in one
data template used
go with Sitecore Rocks
4
Author Insert Options
covered in Topic 2.5

8.0.0.3 www.sitecore.net/training
Review – Data Template Inheritance
Q In which scenario would you use Q What happens if the same field
data template inheritance? section name is used in multiple
templates in a data template's
 When fields are repeated in multiple inheritance tree?
data templates
 The field sections will merge
Q Why is it important to think of
your data template creation and  Fields will be listed under this single
section
inheritance structure from the
beginning? Q What happens if the same field
 Refactoring template inheritance may name is used in two separate
cause data loss inherited data templates?
 Fields do not merge
Q By default, all data templates
eventually inherit from which  Both fields will appear
Sitecore data template?  Best to avoid reusing the same field
 Standard Template names

8.0.0.3 www.sitecore.net/training
Topic 2.3
Standard Values
By the end of this topic you will be able to:

Create a data template’s standard values using Sitecore Rocks


Use standard values to set the default content of a data template
Use tokens to insert dynamic field values
Reset an item’s field values back to the standard values of its data template
List item properties which should be set on its data template standard
values according to recommended practice

8.0.0.3 www.sitecore.net/training
Standard Values Allow You to Define Defaults

Standard values contain


all inherited fields

Standard values item Standard values allow you to…


• Manually create • Specify default field values
• Child item of the data template • Set dynamic field values using tokens
• Includes the data template fields and all
inherited fields We will also cover assigning…
• Always named __Standard Values • Insert options
• Default look and feel
• Default workflow state

8.0.0.3 www.sitecore.net/training
Standard Values and Inheritance
Base data template

inheritance
Inheriting data template

Standard Value
Option to override
information

Instance of item

Standard Value Note: Field Information in Sitecore


Option to override
information Rocks is hidden by default

8.0.0.3 www.sitecore.net/training
Tokens
Tokens are replaced the moment an item is created
• $name, $id, $time, $parentid (further examples in Student Manual)
• You can add your own tokens programmatically
Instance of an item
Item is created

token is
evaluated

Standard Values Item Notice [standard value] label


Older(ifitems
the field valuebefore
created is null)
token insertion will literally
contain the token – why?

8.0.0.3 www.sitecore.net/training
Item Naming Conventions
Business names preferred approach:
• Name items using spaces so tokens expand in fields correctly
• Hyphenated item names result in hyphenated field values where tokens were used

New item in tree


New item
Result in field value
from token replacement
Options for using spaces or hyphens:
• Create item name using spaces, then rename item replacing spaces with hyphens
This avoids item URL’s being encoded, %20 will replace any spaces
• Add entry to <encodeNameReplacements> in web.config
• Can write custom solution (pipeline, event, rules)
Requires hyphen to be illegal
character in item names
8.0.0.3 www.sitecore.net/training
Demo 2.3 – Standard Values, Tokens and
Default Values
Demo objectives
• Create standard values for the Content Base template

• Add default values, for example, Heading in Content Base

• Add $name into the Content Base template

• Create a new Trip item and view existing item

Add ‘Lorem Ipsum…’

8.0.0.3 www.sitecore.net/training
Exercise 2.3 – Create Standard Values

Lab 2.3.A Create standard values and populate with tokens and sample content

Lab 2.3.B Create a new Trip item

8.0.0.3 www.sitecore.net/training
Review – Standard Values
Q Describe the standard values Q What are the two types of
item default field values?
 Always named __Standard Values  Dynamic (uses tokens) and Static.
 Child item of owning data template Q How do tokens work?
 Just like other items – it contains all  Tokens are replaced when an item is
inherited fields created. For example, there are
tokens for the name of the item or the
Q What type of settings can be ID of the parent item.
applied to standard values?
Q Name three tokens:
 Default field values, default insert
options, default presentation, default  $name, $date, $id, $parentid,
Workflow $parentname, $time, $now

8.0.0.3 www.sitecore.net/training
Topic 2.4
Insert Options

By the end of this topic you will be able to:

Explain why authors require insert options


Assign insert options to a data template’s standard values
Explain why Sitecore recommends assigning insert options to
standard values

8.0.0.3 www.sitecore.net/training
What Are Insert Options?
Why Insert Options?
• Authors require a list of allowed item types (data templates)
• Developers and administrators are less restricted

Insert Options…
• Define allowed child items
• Allow authors to build multiple levels Insert
Insert options
Options
of content in the tree defined
definedbyby
• Reduce risk of human error developers
developers
• Usually defined on standard
values
• Can be overridden on an item

8.0.0.3 www.sitecore.net/training
Demo 2.4 – Set Insert Options
Demo objectives
• Assign insert options to the Holidays section data template

• Create a new Trip item under Family Holidays item

8.0.0.3 www.sitecore.net/training
Exercise 2.4 – Insert Options

Lab 2.4.A Add Trip as an insert option on the Holidays Section data template

8.0.0.3 www.sitecore.net/training
Review – Insert Options
Q What are Insert Options? Q Why is it a good idea to
 A list of item types (data templates) configure insert options on
that can be created under a specific standard values?
item  All items using that data template will
have the same insert options
Q Where should insert options be
configured?
 On the data template’s standard
values which can be overridden at
item level

8.0.0.3 www.sitecore.net/training
Summary and Optional Lab
Topic 2.5

This topic covers:

A summary of key vocabulary


A summary of standard values versus data templates
A summary of key steps
An optional lab

8.0.0.3 www.sitecore.net/training
Key Vocabulary
Data Template
Defines an item’s type. Contains field sections and fields. Should always have a
unique icon. Used to create items.
Field
Holds content. Can be different types: Single-Line Text, Rich Text, Image, General
Link and more. Type determines the interface that the author sees for editing that
field.
Data Template Inheritance
Data templates can inherit fields and field sections from other data templates.
Reduces duplication.
Standard Values
__Standard Values is a child item of a data template and is the mechanism for
defaults when items are created.
Insert Options
List of item types that can be inserted by authors as a child of a particular item.

8.0.0.3 www.sitecore.net/training
Data Template vs. Standard Values

1. Default
1. Field Sections
Field Values

2. Default
2. Fields Insert Options
Data Standard
Template Values 3. Default
3. Template Icon Presentation Details*

4. Base template 4. Default


Inheritance Workflows*

* Covered in later modules

8.0.0.3 www.sitecore.net/training
Review of Steps
Content
Data Templates
• Field sections
• Field names/types
• Icon
• Inheritance
1
Data Template
? ?
Standard Values
• Default values
• Insert Options
• Tokens Content Items
• Create the 2
tree structure

8.0.0.3 www.sitecore.net/training
Exercise 2.5 – Optional Lab

In this lab, you will use the skills you have learned in Module 2 to
create a Bicycle data template.

See student workbook for further instructions. For detailed steps, refer to previous
labs.

8.0.0.3 www.sitecore.net/training
Layout Not Found
What happens when you…
• Preview http://basicsitecore/Family Holidays

8.0.0.3 www.sitecore.net/training
Module 3
Presentation
Presentation Is Dynamic and Modular
Preparing to Build with a Visual Studio Project
Creating a Layout
Creating Components
Dynamic Binding
Rendering Content
Summary and Optional Lab

8.0.0.3 www.sitecore.net/training
Presentation Is Dynamic and Modular
Topic 3.1

By the end of this topic you will be able to:

Explain how Sitecore resolves a page


Define presentation details

8.0.0.3 www.sitecore.net/training
How Sitecore Resolves a Page
Static HTML
• URL points to an HTML file with the same name

Sitecore
• URL points to an item in Sitecore, which has a set of rendering instructions

8.0.0.3 www.sitecore.net/training
A Detailed Look at a Request
Browser IIS Sitecore

Requests URL
Passes request

Run HttpRequestBegin pipeline Map request to a


content item

Presentation
Run RenderLayout pipeline assembled dynamically
from configuration in
Stream response back presentation details

Browser IIS Sitecore

8.0.0.3 www.sitecore.net/training
Presentation Details
Presentation details determine the
appearance of an item when it is
requested by the browser

Modular components
on a canvas

Modified behind the scenes by


the Experience Editor

Definition items map to physical files on the


file system – like .aspx and .ascx

8.0.0.3 www.sitecore.net/training
Demo 3.1 – Modify the Presentation with
Experience Editor
Demo objectives
• Create a new Standard Content item in Traincore
• Use Sitecore Rocks to view presentation details
• Add a Banner and general widget component to the newly created page
• Use Sitecore Rocks to view changes in presentation

8.0.0.3 www.sitecore.net/training
Review – Presentation Is Dynamic and Modular

Q What are presentation details? Q Describe how Sitecore resolves a


 A configuration that determines what page in comparison to a static
an item looks like when requested by HTML site.
the browser  Normally, a URL points to an HTML
file. In Sitecore, a request maps to an
item and the page is dynamically
assembled from smaller pieces.

8.0.0.3 www.sitecore.net/training
Preparing to Build with Visual Studio
Topic 3.2

By the end of this topic you will be able to:

Break a design into components


Set up a Visual Studio project to work with Sitecore

8.0.0.3 www.sitecore.net/training
Turn Your Design into Components
Break designs into units of reusable functionality
Consult your front-end developers, designers and user experience designers!

Holidays Section Trip


Componentized Componentized

8.0.0.3 www.sitecore.net/training
How Would You Componentize Your Own Sites?

Inspecting your site:


• Choose a site that a member of the group has worked on, or ask the instructor to
suggest a known Sitecore site
• Look at several different page types. How would you break these pages up into
components?
• Is there any nesting of components – such as content within two or three-column
grids?

8.0.0.3 www.sitecore.net/training
Create a Visual Studio Project
Presentation details map to physical files on the file system
• Sitecore is an ASP.NET application – it has a web root and web.config
• Create and manage presentation files in a normal Visual Studio project
• Connect Sitecore Rocks to project – you never have to leave Visual Studio!

8.0.0.3 www.sitecore.net/training
Walkthrough 3.2 – Creating a Project
Walkthrough steps
• Create a new ASP.NET Empty Web Application (C#) project in Visual Studio named
BasicSitecore to match our Sitecore instance
• Move the .csproj and the Properties folder into the web root (check permissions)
• Include the layouts folder in project
• Add a reference to the Sitecore.Kernel.dll
o It is important: set Copy Local property to False
• Connect the project to Sitecore Rocks

Note: We will cover using a project inside the web root in this module

8.0.0.3 www.sitecore.net/training
Review – Preparing to Build
Q What is the name of the main Q What happens if you do not set
Sitecore .dll? Copy Local to False for your
 Sitecore.Kernel.dll Sitecore.Kernel reference?
 Some dll’s in bin folder will be deleted
and you will need to get the full set
from another installation to continue
working.

8.0.0.3 www.sitecore.net/training
Creating a Layout
Topic 3.3

By the end of this topic you will be able to:

Create a Layout using Sitecore Rocks


Assign a Layout to a data template’s standard values

8.0.0.3 www.sitecore.net/training
One Layout for All Items in Our Site
A Layout is a canvas or the ‘scaffolding’ for a site
• The training site BasicSitecore defines a single shared Layout for all items within
the site (per device)
• Assign a layout on standard values (consider setting layouts on base templates)
• Build up page design using components

8.0.0.3 www.sitecore.net/training
What Is a Layout?
A layout is…
• An .aspx file on the file system See lab instructions for
details on how to create a
• A corresponding Layout definition item in the tree layout in Sitecore Rocks!
• Linked by the Path field

Note: The item and the file can be referred to as a “layout”

8.0.0.3 www.sitecore.net/training
Assigning a Layout
Items must have a layout to be viewed as web pages
• Layouts are part of an item’s presentation details
• Recommended practice – assign Layouts to the data template’s standard values
• An item can have one layout per device* (mobile, print, RSS)

Device list Uses the Main Layout

* More on devices in Module 6

8.0.0.3 www.sitecore.net/training
Demo 3.3 – Creating and Assigning a Layout
Demo objectives
• Create a layout using Sitecore Rocks – this creates both the file and the item
• Paste sample HTML into the layout .aspx file
• Assign a layout to the Content Base data template’s standard values
• Preview an item that inherits from Content Base

8.0.0.3 www.sitecore.net/training
Exercise 3.3 – Create and Assign a Layout

Lab 3.3.A Create a layout named Main

Lab 3.3.B Paste sample HTML into the Main.aspx file

Lab 3.3.C Assign a layout to Content Base template’s standard values and preview
the Family Holidays item

8.0.0.3 www.sitecore.net/training
Review – Creating a Layout
Q In a Sitecore context, what is the Q How do you configure an item’s
name given to an .aspx file? presentation details in Sitecore
 A layout Rocks?
 Right-click->Tasks->Design Layout or
Q How is a layout definition item CTRL+U.You can also use Commandy
connected to a layout file?
 The Path field on the layout definition
Q How many layouts can you
item points to the location of the assign to a single item?
.aspx file  One – per device!

8.0.0.3 www.sitecore.net/training
Creating Components
Topic 3.4

By the end of this topic you will be able to:

Create a sublayout using Sitecore Rocks


Name three types of Sitecore components

8.0.0.3 www.sitecore.net/training
Movable, Reusable Components
Pages are assembled from smaller units of functionality
• Various types – collectively known as components
• Components can be re-used and moved and they can be nested
• Arranged to create a unique page design

8.0.0.3 www.sitecore.net/training
What Is a Component?
A component can be a… We will use the term
component
• Sublayout (Sitecore’s name for a Web User Control)
• XSLT Rendering
• Sitecore Web Control There are Sitecore MVC
alternatives – see videos!

All components consist of…


Definition item in Sitecore: File on the file system:
/sitecore/Layout/Sublayouts .ascx (Sublayout)
/sitecore/Layout/Renderings .xslt (XSLT rendering)

Linked by a Path field on definition item

8.0.0.3 www.sitecore.net/training
What Is a Sitecore Sublayout?
A Sitecore Sublayout is: See lab instructions on how
to create a Sublayout in
• Most commonly used component in a web forms Sitecore Rocks!
implementation
• An .ascx file on the file system (with normal .ascx.cs code behind)
• A corresponding sublayout definition item in the Sitecore tree
• Linked by the Path field

8.0.0.3 www.sitecore.net/training
Demo 3.4 – Creating a Sublayout
Demo objectives
• Create a sublayout named Introduction
• Move markup from the Main.aspx layout into the Introduction.ascx sublayout

8.0.0.3 www.sitecore.net/training
Exercise 3.4 – Create a Sublayout

Lab 3.4.A Create a sublayout named Introduction


Lab 3.4.B Move the heading, text and image sample HTML from Main.aspx into
Introduction.ascx

But how do we piece the page back together?


Dynamic Binding – Topic 3.5

8.0.0.3 www.sitecore.net/training
Review – Creating a Component
Q Name three different types of Q A component consists of a file on
Sitecore components the file system and…
 Sublayout, XSLT rendering, web  A definition item in Sitecore
control
Q How does a component definition
Q What type of file is a Sitecore item know where to find the
sublayout? associated file?
 .ascx  By a Path field on the definition item

8.0.0.3 www.sitecore.net/training
Dynamic Binding
Topic 3.5

By the end of this topic you will be able to:

Assemble a page using dynamic binding


Explain the pros and cons of static binding

8.0.0.3 www.sitecore.net/training
Dynamic Binding of Components to a Layout

Placeholders are required


• Declare placeholders within
markup
• Give them a unique key
• Bind any number of components
to a placeholder in an item’s
presentation details

8.0.0.3 www.sitecore.net/training
What Are Placeholders?
• Placeholders are Sitecore controls used in layouts and sublayouts
o Define where components can dynamically be bound to an area of a page
o Can be added anywhere in the markup of layouts or sublayouts
• Identified by an attribute called Key (the ID attribute is not required)
• The Placeholder is added directly in the markup:
<sc:Placeholder Key=“gallerycontainer" runat="server" />

Lowercase Keys are recommended, easier


Traincore to distinguish between component names
in Experience Editor

(Module 7 covers Placeholder Settings items, which are required by Experience Editor)

8.0.0.3 www.sitecore.net/training
Binding Components to Placeholders
Presentation Details: Tasks->Design Layout or CTRL+U

Recommended practice – define


presentation defaults on data
template standard values!

Name placeholder Keys carefully – stored


as a string and not easily changed

maincontent
content

8.0.0.3 www.sitecore.net/training
Demo 3.5 – Holidays Section Presentation Details

Demo objectives
• Create a maincontent placeholder in Main.aspx
• Bind the Introduction component to the maincontent placeholder on Content
Base template’s standard values
• Preview Family Holidays
• Add an additional Introduction component to Family Holidays
• Reset presentation back to what it looked like prior to adding the additional
component

8.0.0.3 www.sitecore.net/training
Dynamic vs. Static Binding
What are the benefits of dynamic binding?
• New page types can be assembled from existing components
• Changes to page structure do not require a developer
• Supports content re-use (more in Module 5)
• Supports Sitecore’s personalization and testing features

Static binding
• Some components, like headers and footers, may be statically bound
<sc:Sublayout Path="/layouts/Header.ascx" runat="server" />

8.0.0.3 www.sitecore.net/training
Designs Change
Resetting Presentation
• Editors may modify appearance of a page using Experience Editor
• Changes are stored on the item
• Presentation can be reset back to the default standard values
• Reset buttons available in Experience Editor and Content Editor for editors
• Developers can reset in Sitecore Rocks
Experience Editor

Content Editor

Sitecore Rocks

8.0.0.3 www.sitecore.net/training
Exercise 3.5 – Binding Components
Bind components to placeholders on standard values

Lab 3.5.A Create a placeholder in Main.aspx


Lab 3.5.B Bind Introduction to the maincontent placeholder on Content Base template’s
standard value
Lab 3.5.C Create and bind Trip Overview component to Trip template’s standard values

8.0.0.3 www.sitecore.net/training
Review – Dynamic Binding
Q What is the Sitecore control that Q Name the property that you
must set on a placeholder to
allows you to dynamically bind identify it.
components to a page?
 Key
 sc:Placeholder
Q If all items of a particular type
Q What is the Sitecore control to require a particular component,
statically include sublayouts on a where should these presentation
details be configured?
page?
 On the standard values of the data
 sc:Sublayout template

Q Describe the process to bind a Q What type of components might


be good candidates for static
component to a placeholder? binding?
 Open Design Layout, Add Rendering  Page scaffolding, like headers and
(the component) and edit the added footers
Rendering to associate a placeholder
key to the Rendering

8.0.0.3 www.sitecore.net/training
Rendering Content
Topic 3.6

By the end of this topic you will be able to:

Output content using a number of Sitecore controls


Use Sitecore control parameters to vary the output of Sitecore controls

8.0.0.3 www.sitecore.net/training
How Do You Output Content?
Field property
Sitecore Item is mandatory
Introduction.ascx
<sc:Text Field="Heading"
runat="server" />

<sc:Text Field="Main Content"


runat="server" />

<sc:Image Field="Main Image"


runat="server" />

• Sitecore field controls are used to output an


item’s content
• There are different controls for
different field types

8.0.0.3 www.sitecore.net/training
Sitecore Controls Have Optional Attributes
Sitecore offers a different set of options depending on the control
On Sitecore’s Image control, you can configure:
• CssClass for a particular instance of an image
• Dynamically resize with MaxWidth or MaxHeight (caches an image of that size on the
server!)

<sc:Image Field="Main Image" MaxWidth="200" runat="server" />

In code, your settings trump the author settings


• If you set an image’s Alt text in code, an author’s changes in the Content Editor will
not take effect. Determine whether you want authors to have control of this property

8.0.0.3 www.sitecore.net/training
Demo 3.6 – Outputting Content
Demo objectives
• Swap all static content with Sitecore controls

8.0.0.3 www.sitecore.net/training
Exercise 3.6 – Outputting Content

Lab 3.6.A Swap all sample content for Sitecore controls

8.0.0.3 www.sitecore.net/training
Review – Outputting Content
Q Name three specialized Sitecore Q Name the one mandatory
field controls property that must be specified
 <sc:Text />, <sc:Date>, <sc:Image /> on the Sitecore web controls
 Field
Q How can Sitecore help you resize (note: on <sc:FieldRenderer />, the
images dynamically? equivalent is FieldName)
 Set MaxWidth and/or MaxHeight on
the sc:Image tag

8.0.0.3 www.sitecore.net/training
Summary and Optional Lab
Topic 3.7

This topic covers:

A summary of key vocabulary


The Renderings field
A summary of key steps
An optional lab

8.0.0.3 www.sitecore.net/training
Vocabulary
Presentation Details
• An item’s presentation details are instructions that specify which layout and
components are used and which placeholders to use for dynamically binding
components.

Layout
• A layout is your page canvas. It is linked to an .aspx file on the file system, which may
also be referred to as a ‘layout’. You can have one layout per item per device.

Component
• A unit of functionality. All components have a definition item in the Sitecore tree and a
file on the file system. Components can be: Sitecore Sublayouts (.ascx), XSLT renderings
(.xslt), or web controls (.cs).

Placeholder
• A placeholder is a Sitecore control that determines where on a page a component can
be inserted. It is added to regular HTML markup and must have a key.

8.0.0.3 www.sitecore.net/training
The Renderings Field
All presentation is stored in the Renderings field as custom XML
When presentation details are changed, the raw value of the renderings field is
updated. This XML contains all information about layout, devices, components and
placeholders.

On an item, this field


contains a layout delta.
More on that in Module 5!

8.0.0.3 www.sitecore.net/training
Review of Steps
Content Presentation Binding
Data templates
• Field sections 3 5
• Field names/types Create layout
• Icon • Device
• Inheritance • Layout .aspx Data template
1 standard values
Data template • Presentation
standard values 4 layout details
Create
• Default values components • Placeholders
• Insert options
• Sublayout .ascx
• Presentation details
• Web Control .cs
• Workflows *
• XSLT (.cs)
2 Content Items
• Create the tree structure
8.0.0.3 www.sitecore.net/training
Exercise 3.7 – Optional
In this lab, you will use the skills you have learned in Module 3 to
build up default presentation for the Bicycle data template.
See the student workbook for further instructions. For detailed steps, refer to
previous labs.

8.0.0.3 www.sitecore.net/training
Module 4
Sitecore API

Basic API Concepts and Retrieving Items


Item Links
Creating, Deleting and Modifying Items
Working with Complex Fields

8.0.0.3 www.sitecore.net/training
Topic 4.1
Basic API Concepts and Retrieving
Items
By the end of this topic you will be able to:

Describe the information the Sitecore.Context class provides


Discuss how Sitecore code is debugged in a .NET solution
Use the GetItem() method to retrieve items
Obtain a site’s start item
Describe how to get items from another database

8.0.0.3 www.sitecore.net/training
Sitecore.Kernel Assembly
Sitecore Namespaces
• Sitecore.Data – CRUD operations, item manipulation
• Sitecore.Context – Information about current request
• Sitecore.Links – Links management

Useful utilities
• Sitecore.DateUtil
• Sitecore.IO.FileUtil
• Sitecore.StringUtil
• Sitecore.UIUtil
• Sitecore.MainUtil

8.0.0.3 www.sitecore.net/training
Sitecore Context
• The Sitecore context, exposed by the static Sitecore.Context class, contains
information about the Sitecore installation and the current HTTP request

Which database is being Which item is being viewed?


accessed? Sitecore.Context.Item
Sitecore.Context.Database

What is the current language? Who is the current user?


Sitecore.Context.Language Sitecore.Context.User

• Sitecore.Context assembled when a request is made – some data (for example:


language) is retrieved from cookies
• In a typical request, Sitecore determines properties like the context database,
context language, context item and that item’s presentation details

8.0.0.3 www.sitecore.net/training
Debugging
Sitecore is a regular .NET application
• You can use the usual Visual Studio debugging techniques
• Preview a page that will run the code
• Use Sitecore Rocks (commandy) to Attach to Process… to all w3wp worker
processes
o (F5 not recommended unless after a Sitecore Publish)
• Step through your code

8.0.0.3 www.sitecore.net/training
Demo 4.1.1 – Basic API Concepts
Demo objectives
• Explore Sitecore.Context

Who do you think the context user will be?

8.0.0.3 www.sitecore.net/training
The GetItem() Method
Retrieving items
• Items represented by the type Sitecore.Data.Items.Item
• Items can be retrieved using the GetItem() method:
o Sitecore.Context.Database.GetItem("/sitecore/content/Home");

• GetItem() accepts a Sitecore ID or path to an item


• Whenever possible, IDs or paths should not be hardcoded in your solution
o Keep IDs or paths in one place in your solution. For example, a References.cs file

Retrieving the context site’s start item


• To get the context site’s start item (specified in the <site> node in the
web.config), you can use the following method:

string startPath = Sitecore.Context.Site.StartPath;


Item home = Sitecore.Context.Database.GetItem(startPath);

8.0.0.3 www.sitecore.net/training
Getting Items from Other Databases
• Context.Database points to the web database when browsing the live site
• Context.Database points to the master database when authors edit the site

• If you want to get an item from another database (for example: editing an item in
the master database), get the desired database by name:
Sitecore.Configuration.Factory.GetDatabase("master");

• Use the same GetItem() method directly on the database object:


Database master = Factory.GetDatabase("master");
Item = master.GetItem("/sitecore/content/home");

8.0.0.3 www.sitecore.net/training
Demo 4.1.2 – Retrieving Items
Demo objectives
• Use .GetItem() to retrieve an item by path and ID
• Explore Item properties and methods
• Use .GetChildren() and .Children
o These return a collection of items of type Sitecore.Collections.ChildList

Example:
Sitecore.Collections.ChildList children = item.GetChildren();

8.0.0.3 www.sitecore.net/training
Exercise 4.1 – Render Item Children (30 min)

Lab 4.1.A. Build a navigation sublayout

8.0.0.3 www.sitecore.net/training
Review – Basic API Concepts
Q In which .dll can you find the Q When you are looking at a page
majority of the API? in Experience Editor mode, what
 Sitecore.Kernel is the context database?
 Master
Q When Sitecore makes a request,
what is the name of the static
class that is assembled?
 Sitecore.Context
Q Name four properties that you
might get from Sitecore.Context:
 Context user, language, database and
item

8.0.0.3 www.sitecore.net/training
Review – Retrieving Items
Q Name the method used to Q How should you compare two
retrieve items? items in code?
 GetItem()  Using their IDs

Q Items can be retrieved by path


or…
 By ID
Q What does the
Sitecore.Context.Item.Database
property return in the context of
a live website visitor?
 Web

8.0.0.3 www.sitecore.net/training
Topic 4.2
Item Links
By the end of this topic you will be able to:

State what the ItemResolver does


State what the LinkManager does
Resolve a URL to an item
Resolve an item to a URL
Use URL options to output a URL in a context language
Be able to customize LinkManager

8.0.0.3 www.sitecore.net/training
Item Resolver
item.Name = Family Holidays
Sitecore’s ItemResolver resolves
a URL to an item and can interpret item.DisplayName = Our Holidays
various different URL formats:
item.ID = {F02D3ACC-45B1-45A1-9BD2-
C19B9D81099E}
http://mysite/....
Family Holidays
Family Holidays/
Family Holidays.aspx
Our%20Holidays.aspx
en/Family Holidays.aspx
Family Holidays.aspx?sc_lang=en
?sc_itemid={F02D3ACC-45B1-45A1-9BD2-C19B9D81099E}
~/link.aspx?_id=F02D3ACC-45B1-45A1-9BD2-C19B9D81099E&_z=z

Display Names allow alternative item names for different languages. If the site was translated
into Danish, the content editor would see ‘ferier’ rather than ‘Family Holidays’

8.0.0.3 www.sitecore.net/training
LinkManager and Item URLs
Always use the LinkManager to output an item’s URL
• Use LinkManager.GetItemUrl() – recommended practice; SEO-friendly URL
• Do NOT use LinkManager.GetDynamicUrl() – URL with a GUID!

May require IIS


Customize URL with UrlOptions… configuration changes
• Language embedding, use .aspx, show
language-sensitive Display Name

…or globally in web.config


• Overrides LinkManager completely
• Then can change individual settings

8.0.0.3 www.sitecore.net/training
Demo 4.2 – Retrieving an Item’s URL
Demo objectives
• Retrieve the item URL using LinkManager.GetItemUrl()
• Use UrlOptions to output the Display Name
• Change items to use Display Name in Sitecore

Example:
Item = Sitecore.Context.Database.GetItem("{565A8A17-032F-44AC-B506-
B65F27A31241}");

UrlOptions options = UrlOptions.DefaultOptions;

options.UseDisplayName = true;

string url = LinkManager.GetItemUrl(item, options);

8.0.0.3 www.sitecore.net/training
Controlling Your URLs
Decide how you want to render links
• Individually or globally

URL resolution handled automatically


• Regardless of how a URL comes in, Sitecore URL ITEM
knows which item to map to

Multiple URLs for a single page can be confusing for:


• Google Analytics
• JavaScript third party services
• Web Log Analyzers

8.0.0.3 www.sitecore.net/training
Exercise 4.2 – Render Item Links (10 min)

Lab 4.2.A Rendering subnavigation links

8.0.0.3 www.sitecore.net/training
Review – Item Links
Q What method do you use to Q What object can you pass into
retrieve an item’s URL? the GetItemUrl() method to
 LinkManager.GetItemUrl() customize the way your item’s
URL is rendered?
Q Why should you not use  A UrlOptions object
GetDynamicUrl() for your site’s
front end? Q Where can you customize how
 Unreadable ‘developer’ URL, uses IDs URLs are rendered globally?
 In the LinkManager section of the
web.config

8.0.0.3 www.sitecore.net/training
Topic 4.3
Creating, Deleting and Modifying
Items
By the end of this topic you will be able to:

Describe the implications of choosing the correct database to retrieve an item


from

Choose the correct user to perform an operation on an item


Place an item into an editable state
Create an item
Update a simple item via its raw value
Make a modified item live on the web database
8.0.0.3 www.sitecore.net/training
Fields and Raw Values
All items have a collection of Fields
FieldCollection fields = Sitecore.Context.Item.Fields;

A field’s raw value (value stored in database) depends on the field type

Field type Controls


Single-Line Welcome to the world of Sitecore!
Text
General Link <link text="Read the feature guide"
linktype="internal" url="/Home/holidays.aspx"
id="{54089BF1-790F-44E0-93E4-66BEC9CD61D1}" />
MultiList Field {743C2FAD-0E01-426E-8972-2CCFEBDC20F9}|{243C2FAD-
0E01-C26E-8972-1CCFEBDC20F9}

(More on raw values in Topic 4.4)

8.0.0.3 www.sitecore.net/training
Getting and Setting Raw Values
Access the field value directly…
string fieldValue = Sitecore.Context.Item["Profile Text"];
(note: this returns String.Empty even if field is null)

….or retrieve the field as an object first


Field = Sitecore.Context.Item.Fields["Profile Text"];
string fieldValue = field.Value;

Simple text fields can be changed by setting their .Value


field.Value = "My new value!";

Note: If you bind field.Value to a .NET Literal, it will not be editable in the Experience Editor!

8.0.0.3 www.sitecore.net/training
Demo 4.3.1 – Raw Values
Demo objectives
• View the raw values of items in Sitecore Rocks
• Output raw value to the browser – which will not be editable in the Experience
Editor

8.0.0.3 www.sitecore.net/training
Creating and Editing Items
Seven Steps to Edit or Create an Item:
1. Get the master database – do not edit directly on web database!
2. Change the security context
3. Retrieve an item
(When creating a new item, you need the parent item and a data template ID)
4. Put the item into an editing state use Editing.BeginEdit() in a try/catch
block
5. Set the item’s field values to the new values
6. Save changes with Editing.EndEdit()
7. You must publish your changes if you want them to appear in the web database

8.0.0.3
 www.sitecore.net/training
Security and Editing Contexts
Security context Editing an Item
• Requests are made in the context • Editing and renaming must happen in
of anonymous or currently an Editing.BeginEdit() transaction
logged-in user
• You can force code to run regardless try
{
of context user’s permissions: newItem.Editing.BeginEdit();

Field heading = newItem.Fields["Heading"];


o Switch to another user if (heading != null)
{
using (new UserSwitcher(user)){} heading.Value = “Vacations";
}

newItem.Editing.EndEdit();
o UserSwitcher is safer in production, }
however you can also use
catch
SecurityDisabler {
newItem.Editing.CancelEdit();
}
using (new SecurityDisabler()){}

8.0.0.3 www.sitecore.net/training
Demo 4.3.2 – Creating and Editing an Item
Demo objectives
• Programmatically create an item based on the Trip template

Tip: Use Sitecore.Data.Items.ItemUtil.ProposeValidItemName() to ensure your item’s name


adheres to convention

8.0.0.3 www.sitecore.net/training
Recommended Practices
You will not typically create items for your live site (the CD
environment)
• But you may have to do it in the CM server: data import, web service…

What are the options for adding content from within the CD?
• Item Web API (bundled with 7.2+)
• Custom web API or service
• Third party service (high volume user-generated content, such as comments)

Should user-generated content live in Sitecore?


• Do authors need access?
• Is this content better suited to an external system?

8.0.0.3 www.sitecore.net/training
Exercise 4.3 – Create and Edit Items

Lab 4.3.A Create Comment templates Unlikely to be done in production,


but we’ll do it for practice!
Lab 4.3.B Create a CommentsForm sublayout

Lab 4.3.C Create comment items

Lab 4.3.D Populate comments item with


form content

8.0.0.3 www.sitecore.net/training
Review – Creating, Deleting and Modifying

Q Sitecore security is an extension Q When creating or editing an item,


of… the code must be executed with
 Standard .NET membership the appropriate security rights.
Name two ways that this can be
Q All code is executed in the context done
of…
 UserSwitcher or SecurityDisabler
 The current user
Q What affects whether or not a Q How do you put an item into an
piece of code will run? editing state?
 That user’s permissions  myItem.Editing.BeginEdit()

Q What permissions does Q Why should you create / edit items


extranet\anonymous lack by in the master rather than the web
default? database?
 Permission to create or edit items  Web overwritten by publish

8.0.0.3 www.sitecore.net/training
Review – Creating, Deleting and Modifying
Items
Q Why is it a bad idea to output a Q Which field types are suitable for
field’s value straight to the editing using the .Value
screen? property?
 Not editable in Experience Editor and  Simple text fields. For example,
complex fields contain custom XML Single-Line Text

8.0.0.3 www.sitecore.net/training
Topic 4.4
Working with Complex Fields
By the end of this topic you will be able to:

Describe the correct way to retrieve complex field values


Get and set content in complex fields
Use ImageField, LinkField, ReferenceField and MultilistField
Render fields using the FieldRenderer

8.0.0.3 www.sitecore.net/training
RECAP: Field Types (previously mentioned in 2.2)

Field type determines


• Raw value that is stored in the database
• Sitecore API field class used for that field type
• Type of source accepted in the Data Source (GUID shown below)
• Editor control in Content Editor Click Build to set the
Data Source

Final result after Editor control in


building Data Source Content Editor

8.0.0.3 www.sitecore.net/training
Simple Fields
Simple fields contain text only
Field Raw value Source Control Class
Singe-Line Text
Multi-Line Text text n/a <sc:Text /> Field
Integer
Path,
Rich Text text <sc:Text /> Field
GUID
Droplist
Path,
Grouped <sc:Text />
text GUID, Field
Droplist Query

8.0.0.3 www.sitecore.net/training
Complex Fields
Field Raw value Source field Control Class
Image Custom XML Path, GUID <sc:Image /> ImageField
Date ISO date n/a <sc:Date /> DateField
General Link Custom XML n/a <sc:Link /> LinkField
Droplink
Grouped
Single GUID Path, GUID, Query n/a ReferenceField
Droplink
Droptree
Multilist
Path, GUID, Query
Checklist Pipe-
Treelist delimited Path, GUID, Query (root), n/a MulitlistField
GUIDs Parameterized
TreelistEx
Datasource
1 (true) or
Check box n/a n/a CheckboxField
not 1 (false)
File Custom XML Path, GUID n/a FileField

8.0.0.3 www.sitecore.net/training
Base Field Object
Sitecore.Data.Fields.Field

Example of using a Field object:


Sitecore.Data.Fields.Field heading = item.Fields["Heading"];
string fieldValue = heading.Value;

Examples of Specific Field objects


Namespace: Sitecore.Data.Fields

ImageField myImage = item.Fields["Main Image"];


LinkField myLink = item.Fields["Company URL"];
ReferenceField myRelatedItem = item.Fields["Holiday Type"];
MultilistField myRelatedItems = item.Fields["Related Trips"];

8.0.0.3 www.sitecore.net/training
Raw Value of a Rich Text
Example of the raw value of a Rich Text field containing a link:

<p>Have an <a
href="~/link.aspx?_id=992233B83B0447F4B23BE548AACED6AA&amp;_z=z">awesom
e holiday</a> with us!</p>

Notice the URL – this uses non-SEO Notice _z=z in the URL. This is a
friendly GetDynamicUrl() terminator, everything after this is
treated as a normal querystring

8.0.0.3 www.sitecore.net/training
ImageField Object
Sitecore.Data.Fields.ImageField

Example of using an ImageField object:


ImageField imageField = item.Fields["Banner"];

MediaItem mediaItem = imageField.MediaItem;

string altText = imageField.Alt;

An Image field’s raw value


<image mediapath="/BaseCore/Images/Holiday Image"
mediaid="{743C2FAD-0E01-426E-8972-2CCFEBDC20F9}"
src="~/media/743C2FAD0E01426E89722CCFEBDC20F9.ashx" />

8.0.0.3 www.sitecore.net/training
LinkField Object
Sitecore.Data.Fields.LinkField

Example of using a LinkField object:


LinkField linkField = item.Fields["Search Engine"];
ID targetID = linkField.TargetID;
string linkText = linkField.Text;
string linkType = linkField.Type;

A General Link field’s raw value


<link text="Read more" linktype="internal" url="/Home/holidays.aspx"
id="{54089BF1-790F-44E0-93E4-66BEC9CD61D1}" />

8.0.0.3 www.sitecore.net/training
ReferenceField Object
Sitecore.Data.Fields.ReferenceField

Example of using a ReferenceField object:


ReferenceField refField = item.Fields["Featured Trip"];
Item targetItem = refField.TargetItem;

Used with Sitecore Data Types


• Droplink
• Grouped Droplink
• Droptree

The raw value of those field types:


{54089BF1-790F-44E0-93E4-66BEC9CD61D1}

8.0.0.3 www.sitecore.net/training
MultilistField Object
Sitecore.Data.Fields.MultilistField

Example of using a MultilistField object:


MultilistField listField = item.Fields["Related Trips"];
IEnumerable<Item> itemList = listField.GetItems();

listField.Add(tripItem.ID.ToString()); // Add item


listField.Remove(tripItem.ID.ToString()); // Remove item

Used with Sitecore Data Types


• Multilist
• Checklist
• Treelist
• TreelistEx

The raw value of those field types:


{54089BF1-790F-44E0-93E4-66BEC9CD61D1}|{14289BF1-29AF-4EE0-93E4-66BEC9CD62D4}

8.0.0.3 www.sitecore.net/training
Some Fields Can Be ‘Rendered’
Rendering images, links, text and dates for web pages
• The FieldRenderer pipeline can turn raw values that are unfit for websites into
rendered field values that can be used on web pages
• For example, this is an Image field’s raw value in the master database:

<image mediaid="{743C2FAD-0E01-426E-8972-2CCFEBDC20F9}"
mediapath="/BaseCore/Images/Holiday Image"
src="~/media/743C2FAD0E01426E89722CCFEBDC20F9.ashx" />

For that same Image field, here is the rendered HTML tag:
<img src="/~/media/BaseCore/Images/Holiday Image.ashx" />

Some fields cannot be ‘rendered’


• Check boxes
• Lists (Multilist, Checklist, Treelist or TreelistEx)
• References (Droplink, Grouped Droplink or Droptree)
• Files
8.0.0.3 www.sitecore.net/training
FieldRenderer.Render()
Use FieldRenderer.Render() to get rendered field values in
code-behind
string strRendered = FieldRenderer.Render(Sitecore.Context.Item, "Image");

Sitecore controls use


this method too!

Why should you use FieldRenderer.Render()?


• Transforms field content into valid HTML – Sitecore controls ultimately go through this
method
• Automatically makes fields editable in Experience Editor
• Allows you to pass in parameters that match the ones available in Sitecore controls –
for example: image max width
• Translates dynamic links in Rich Text Editor fields into SEO-friendly URLs

8.0.0.3 www.sitecore.net/training
Render() Method Parameters
Different Parameters for the Render() Method
• Image – image formatting string, such as “w=120&as=1” for width of 120 pixels
and allow stretching the image

FieldRenderer.Render(item, "Main Image", "w=120&as=1");

• Date – date formatting string, such as “format=MM/dd/yyyy”


FieldRenderer.Render(item, “Trip Date", “format=MM/dd/yyyy");

Which parameters take precedence?


• Hard-coded parameters override any author-entered property
• For example, if a user specified an image field width of 300 in the Content
Editor and a developer specified a width of 120 using the Render() method’s
parameter, the rendered image width will be 120

8.0.0.3 www.sitecore.net/training
Demo 4.4 – Using the FieldRenderer
Demo objectives

• Use the FieldRenderer.Render() method with a few parameters to output an


Image field

8.0.0.3 www.sitecore.net/training
Exercise 4.4 –Complex Fields (50 min)

Lab 4.4.A Populate a comment link field

Lab 4.4.B Render list of comments

8.0.0.3 www.sitecore.net/training
Review – Complex Fields
Q Why is it a bad idea to output raw Q What method should you use to
values to the screen? render the contents of text, date,
 Not editable in Experience Editor, image and link fields to the screen
complex field types will not make (and why)?
sense – images, for example  FieldRenderer.Render() – Experience
Editor support, transforms custom
Q Name the best suited field object XML, transforms Rich Text links
for the following field types:
single-line text, treelist, droplink, Q Why are you unable to render a
general link: multilist field to the page using
 Field, MultilistField, ReferenceField, .Render()?
LinkField  It contains IDs, not readable content

8.0.0.3 www.sitecore.net/training
Module 5
Advanced Presentation Concepts

Reusable Content
Layout Deltas

8.0.0.3 www.sitecore.net/training
Topic 5.1
Reusable Content

By the end of this topic you will be able to:

Define a data source


Be able to retrieve the data source from a component
Describe the benefits of using parameters
Set and retrieve parameters
Describe what the ParseURLParameters utility does

8.0.0.1 www.sitecore.net/training
Demo 5.1.1 – What Is a Data Source?
Demo objectives
• Using TrainCore in Experience Editor design
mode, change a general widget’s data source
• Add an additional general widget to the page
• Illustrate the reuse of components and
content

8.0.0.3 www.sitecore.net/training
What Is a Data Source?
Allows your component to display content from an item that is not the context item

Benefit?
Reusable content and components prepare your solution for Experience Marketing
implementation

8.0.0.3 www.sitecore.net/training
Data Sources Allow..
• A component that takes data from an item that is not the context item
• Content and components need to be reusable and Experience Marketing ready
• You use GUID’s and physical paths to items
in the Data Source field

8.0.0.3 www.sitecore.net/training
Using the API for Sublayout Data Sources
• Sublayouts are just .NET user controls, no prior method to retrieve data sources
• To get a sublayout’s datasource, you can use the following snippet in your code-
behind:

var datasource = Attributes["sc_datasource"]; //GUID as string

Item datasourceItem = Sitecore.Context.Database.GetItem(datasource);

8.0.0.3 www.sitecore.net/training
Forcing Controls to Use the DataSource
By default the target of a Sitecore control is the context item
• If you use an <sc:Text /> without explicitly setting the item that it should target, it
will try to render the specified field from the context item.
• To force Sitecore controls to target the data source, you can either set the
.Item property or the .DataSource property:

<sc:Text Field="Widget Heading" ID="Heading" runat="server" />


Heading.Item = myItem

OR

Heading.DataSource = "{6C0EB349-5FBA-481C-A350-7B9ECAD7D394}"

Or you can set the control’s data source or item property directly in the .ascx file!

8.0.0.3 www.sitecore.net/training
Demo 5.1.2 – Data Source API
Demo objectives
• Modify the Trip component to accept a data source

8.0.0.3 www.sitecore.net/training
Component Rendering Parameters

• Rendering parameters allow properties to be set per instance of a component


• Rendering parameters are stored as Key Value Pairs
• Both the Key and the Value are plain text

Component’s
parameters in
Experience Editor

8.0.0.3 www.sitecore.net/training
Retrieve Rendering Parameters Using the API
Rendering parameters are stored as strings, to retrieve parameters in
code for…
• Sublayouts
string parameters = Attributes["sc_parameters"];

• Web Controls
Use the .Parameters property

Sitecore has a utility for turning parameters into a NameValueCollection:


var nvcParameters = Sitecore.Web.WebUtil.ParseUrlParameters(parameters);

Then, retrieve values as usual from a NameValueCollection, that is:


nvcParameters["CssClass"]

8.0.0.3 www.sitecore.net/training
Demo 5.1.3 – Parameters
Demo objectives
• Change the background color for the Trip Overview component from grey to red
using rendering parameters from a parameters template

8.0.0.3 www.sitecore.net/training
Setting an Item’s Presentation and a Component’s Data
Source
Uniqueness:
• Set the presentation on each item and set the data source on each component
instance

Standardization
• Set the presentation on the standard values and set the data source on the
component’s definition item

Combination
• You can start with standardization and have uniqueness in some instances

8.0.0.3 www.sitecore.net/training
Exercise 5.1 – Build a Featured Trip Component
(40 min)
Lab 5.1.A Create component and get the DataSource item

Lab 5.1.B Retrieve the CssClass parameter value

8.0.0.3 www.sitecore.net/training
Review – Data Sources
Q Setting a component data source Q What do parameters allow you
allows that component to _____. to do?
 Receive a reference to an item  Allow properties to be set per
elsewhere in the tree instance of a component

Q How can you force a Sitecore Q How are parameters encoded


control to output the content of when sent to your component?
an item’s data source?  As a URL query string, that is:
 Set DataSource or Item property key1=value1&key2=value2

8.0.0.3 www.sitecore.net/training
Review – Data Sources
Q What utility converts parameter Q Why would you set the
lists to a NameValueCollection? component and the data source
on the standard values’
 WebUtil.ParseUrlParameters() presentation details?
Q Why would you set the data source  When you want all items based on a
particular template to have that
for a component on the component with that particular data
presentation details of an item? source as default
 When that data source should only be Q Why would you set the
used on a particular page component on the standard
values and override the data
source on the item?
 When your component has to appear
on every page but has a different data
source for a particular page

8.0.0.3 www.sitecore.net/training
Topic 5.2
Layout Deltas

By the end of this topic you will be able to:

Define the purpose of layout deltas

8.0.0.1 www.sitecore.net/training
What are Layout Deltas?
• When presentation details are overridden on an item (differ from presentation details
defined on the standard values) – layout deltas get created
• When developers update standard values, the item gets updated via the delta

Item gets updated

• View which items have presentation overridden by …


Right-click the
Quick Action Bar

8.0.0.3 www.sitecore.net/training
A Layout Delta Is Like a Transform
• Presentation details are stored as XML in the Renderings field

Un-edited standard
values presentation

When an item is requested, the layout


Layout delta containing only delta is applied on top of the standard
changes to standard values
values XML. It can add, remove or edit.

8.0.0.3 www.sitecore.net/training
The RenderLayout in the Request
Browser IIS Sitecore

Requests URL
Passes request

Maps request to a
Run HttpRequestBegin pipeline content item

Inspects rendering
Run RenderLayout pipeline property of Content Item,
retrieves presentation
components and invokes
Stream response back them to render the page

Browser IIS Sitecore

8.0.0.3 www.sitecore.net/training
Review – Layout Deltas
Q When does a layout delta get Q How does the XML of a layout
created? delta differ from the XML
 When presentation coming from the specified on a template’s
standard values of an item’s template standard values?
is overridden on that item.  Layout deltas only contain
differences between an item’s
standard value presentation and any
changes made by the author on the
item.

The standard value XML contains all


presentation details.

8.0.0.3 www.sitecore.net/training
Module 6
Real World Solutions

Familiar Concepts
Dealing with Larger Sites
Versioned Layouts
Sitecore Query

8.0.0.3 www.sitecore.net/training
Topic 6.1
Familiar Concepts

By the end of this topic you will be able to:

Describe a realistic Sitecore project setup


Describe a realistic content tree
Describe realistic data template and presentation configuration
Create and configure a new device

8.0.0.3 www.sitecore.net/training
Traincore
A fictional cycling holiday site where users
can search for holidays and get tips and
advice about cycling

Traincore is built according to front-end


and back-end best practices

It deals with common architectural


problems faced by multi-language and
multi-site implementations

It is built to support Experience Editor and


the personalization and analytics aspects
of the Customer Experience Platform (
XP)

8.0.0.3 www.sitecore.net/training
Demo 6.1.1 – Solution , Topology and
Templates
Demo objectives
• Describe Traincore’s project structure
• Describe Traincore’s Sitecore tree

*Notes are available in the workbook.

8.0.0.3 www.sitecore.net/training
Recommended Practice
Project Structure Topology Templates
Abstract functionality in Multiple subfolders for Organize into subfolders
separate projects – for multiple sites
example, Sitecore.Utilities Use author-friendly
Identify reusable content names
Patch in config changes
/App_Config/Include Store content under Use icons
/sitecore/Content
Reference .dlls in a Use multiple base
Libraries folder templates to avoid field
redundancy

8.0.0.3 www.sitecore.net/training
Demo 6.1.2 – Presentation Configuration

Demo objectives
• Describe presentation details of various items – particularly how sublayouts are
nested
• Identify which components accept data sources
• Identify which components make use of rendering parameters

8.0.0.3 www.sitecore.net/training
Placeholder Nesting & Component Re-Use
Levels of Nesting
Layout – e.g. BaseCore

Containers – e.g. Page Container General General


Widget Widget

Columns – e.g. Three Column

Functional blocks – e.g. Widget

Components can be moved & re-used


Containers can be re-ordered
General General
General Widgets can appear in columns, the Widget
Widget
footer, and widgets container

Appearance and content changed using


General General General
parameters and data sources Widget Widget
Widget

8.0.0.3 www.sitecore.net/training
Supporting the Experience Editor
Componentize, componentize, componentize
• Make HTML developers aware of componentization
requirements early
• Separation of data and presentation
• Use the FieldRenderer and Sitecore controls
• Dynamic binding for movable components, static
binding for components with fixed locations

Header
Why Build for the Experience Editor?
• Must form part of requirements – your clients were sold this functionality
• Much easier to change appearance of a page in future if presentation is modular
• Building for Experience Editor means building for Sitecore’s marketing features

8.0.0.3 www.sitecore.net/training
Demo 6.1.3 – Creating a Mobile Site
Demo objectives
• Create a mobile device
• Create and assign a simple Mobile layout to a holiday item’s mobile device
• Output page heading and page content in the layout
• Add a number of existing components (also used by the default device) to the
mobile layout’s placeholder

8.0.0.3 www.sitecore.net/training
Devices
Sitecore architecture supports adaptive design
• Different presentation for the same content based on how the site is accessed
• Functionality is achieved using devices that are
represented as definition items in Sitecore
• Configure presentation details on a template’s
Standard Values (or an item) for a device
• How to change devices:
o Query Strings
• ?sc_device={ID}
• Custom query string defined on device definition item

o The Device attribute for the site in the web.config


o Marketplace modules, such as Mobile Device Detector which uses 51Degrees.Mobi
and the Sitecore Rules Engine
o Custom code such as in a pipeline processor

8.0.0.3 www.sitecore.net/training
Exercise 6.1 – Putting it Together (60 min)

Create a news article data template and standard values


Lab 6.1.A Create a News Article data template
Lab 6.1.B Create the News Article standard values, assign insert options, and
create an article

Create component and bind to placeholder


Lab 6.1.C Create a Related Articles
Sublayout
Lab 6.1.D Output a List of Related
Articles

8.0.0.3 www.sitecore.net/training
Review – Familiar Concepts
Q What can you do with methods Q What kind of content can you
that could be used across display using a General Widget?
multiple Sitecore projects?  Promotions, announcements –
 Abstract code to a generic utilities anything that could be re-used across
project the site

Q Why can’t you preview items Q Name 2 devices you may want to
under Global? target with different
presentation details:
 They do not have presentation details
 Tablets and mobiles
Q Why is the Settings item outside
any individual site folder
structure?
 Values shared across all sites

8.0.0.3 www.sitecore.net/training
Topic 6.2
Dealing with Larger Sites
By the end of this topic you will be able to:

List three considerations that must be taken into account when designing
the architecture for a multi-language site

Name four language configurations and what they do


Account for items without versions
Configure a multi-site solution in web.config
List the limitations of a multi-site solution

8.0.0.3 www.sitecore.net/training
Multi-Language Support
Things to consider when building a multi-language site:
• Components must be able to support different content lengths
• All content must be translated – including labels, button texts, etc.
• Some field values need to be shared across languages
• Build feature that allows users to change the site language
(query string, stored in cookie):
• Restrict author access to their languages only
How does Sitecore choose the language:
• Explicitly in the URL (?sc_lang or /en/holidays)
• Language cookie (traincore#lang)
• <site … language="en-US" /> (per site)
• <setting name="DefaultLanguage" value="en-US" /> (default)

8.0.0.3 www.sitecore.net/training
Remember!
Handle items that do not have language versions
• Check if a version is available in the current language
o The item.Children collection contains children
items if any language has a version, even if
the current language does not have a version
item.Children.Where(i=> i.Versions.Count > 0)

Translation vs. Localization


• Consider that you will be translating the same global content for sites in all
languages or writing different site content for different locations?
o For example, what if Australia wants a different contact form than Denmark?

Language fallback
• There is NO language fallback in Sitecore by default
o Two free modules available from the marketplace provide this functionality
8.0.0.3 www.sitecore.net/training
Demo 6.2 – Multi-Site
Demo objectives
• Show the configuration for multi-site, and add http://traincore-corporate/
• Create an item clone

8.0.0.3 www.sitecore.net/training
Multi-Site
How? Warning!
• Multiple site root items in tree Multi-site can become too complex!
• Shared content outside individual site • URL resolving/generation affected
structure • Shared templates/presentation or
• Individual <site /> node in config (use separate? Duplication vs. complexity
include folder!) • Complex security considerations
• Different host name, start item, • Sites share the same application pool
language, caching options

8.0.0.3 www.sitecore.net/training
Review – Dealing with Larger Sites
Q When will Sitecore use the Q What kind of error checking
language attribute of the site should you do when rendering
definition in the web.config? items to the screen?
 If there is no explicit language in the  Check that each item has a version in
URL nor a language cookie the context language

Q How do visitors to your site Q What are some important


change the site’s language? considerations with a multi-site
 You have to build language switching implementation?
for the front-end yourself – using a  Large codebase, sites affect each
query string, for example others’ performance - see multi-site
slide for more

8.0.0.3 www.sitecore.net/training
Topic 6.3
Versioned Layouts

By the end of this topic you will be able to:

Understand versioned layouts functionality in Sitecore


Describe examples of where to use versioned layouts

8.0.0.3 www.sitecore.net/training
What Do You Do When…
• VP requests you to return back to a previous version of an
item both in terms of content as well as presentation
• You need a seasonal presentation and to be able to quickly
revert back to the original presentation when the season is
over
• You need to create language specific presentations
• Your boss needs to approve a presentation before it goes live
while keeping the previous version intact
• You need to let customers know about an upcoming address
change over time and would like to do so visually (your lab
exercise)

8.0.0.3 www.sitecore.net/training
Introduction to Versioned Layouts
Each version of an item can have its own tailored presentation
• Applies to numbered and language versions
• Behaves the same as content versioning
SHARED LAYOUT is the baseline
presentation we have already used in
this course

FINAL LAYOUT adds customized


presentation for numbered or language
specific versions of an item

8.0.0.3 www.sitecore.net/training
Renderings Fields

• Renderings field stores the shared • Final Renderings field is version


layout specific (not shared)
• It is used by all versions in all • Presentation can be defined on the
languages (shared) item version
• Presentation can be defined on the
• Final Renderings field is for refining
item presentation
standard values or on the item but it
will affect all versions
• Renderings field is for global item
presentation

8.0.0.3 www.sitecore.net/training
Non-Versioned Layout Example
At item level additional presentation
_Renderings Field (Shared Field) information can be added but it must be
used by all item versions
(__Rendering field is shared)

8.0.0.3 www.sitecore.net/training
Versioned Layout Example
__Renderings Presentation can now be versioned like content
Field _ Final Renderings Field for each item version (either numbered or
language)
__Renderings field is shared
__Final Renderings field is item version specific

8.0.0.3 www.sitecore.net/training
Walkthrough 6.3 – Versioned Layouts
Walkthrough Objectives
• Create a new numbered version of the Contact-Us item
• Add a General Widget component to the Final Layout
• Create another numbered version of the Contact-Us item
• Test preview each numbered version of the Contact-Us item

8.0.0.3 www.sitecore.net/training
Review – Versioned Layouts
Q Which shared field is used to Q How do you access the Layout
store presentation information Details window for each item?
for all versions of an item?  In Content Editor or Experience Editor
click the Details command. In
 __Renderings field Sitecore Rocks choose Tasks ->
Design Layout
Q What does the presence of the
__Final Renderings field allows Q What is the difference between
an author to do? the Shared Layout tab versus the
Final Layout tab of the Layout
 To define individual presentation Details window?
details for each version of an item
 The Shared Layout tab is for defining
presentation details for all versions of
an item while the Final Layout tab
focuses on the presentation detail of
that specific version of the item.

8.0.0.3 www.sitecore.net/training
Assembling Presentation Information
Without Final Standard Values Item
Rendering
_Rendering _Rendering

With Final Rendering


Standard Values Item
_Final _Final
_Rendering _Rendering
Rendering Rendering
Item Type Version Specific Item Version Specific

Presentation Detail Information Flow


• Shared Layout option uses __Rendering field
• Final Layout option uses __Final Rendering field
• Going from right to left, if a field has a layout delta, it goes to the field to its left to
gather more presentation information.

8.0.0.3 www.sitecore.net/training
Topic 6.4
Sitecore Query

By the end of this topic you will be able to:

Write simple Sitecore queries using a variety of operators and functions


Write Sitecore queries that use axes
Discuss appropriate uses of Sitecore query and when to opt for the search
API

8.0.0.3 www.sitecore.net/training
Demo 6.4 – Sitecore Query Using XPath Builder
Context Node: /sitecore/content

Absolute query
/sitecore/content/#sitecore-cycling-holidays#/*
Relative query
.//*[@@templatename='Bike'] templatekey is lower
case
Filter by template
/sitecore/content/#sitecore-cycling-holidays#//*[@@templatekey='bike']
Filter by content
/sitecore/content/#sitecore-cycling-holidays#//*[@#Page Title# = 'Home']
Return at index
/sitecore/content/#sitecore-cycling-holidays#/*[3]
Using axes – ancestor-or-self::
/sitecore/content/Home/#sitecore-cycling-holidays#/Home/news/#our-plans-for-the-new-
year#/ancestor-or-self::*[@@templatekey=‘news listing']
./descendant-or-self::*[@@templatekey=‘trip']

8.0.0.3 www.sitecore.net/training
Sitecore Query
Allows you to interrogate an XML representation of Sitecore tree
• Primarily used to limit selection in field source
• Can contain axes (e.g. ancestor-or-self) and wildcards
• Test with Tools -> XPath Builder in Sitecore Rocks
• Sitecore query is not Sitecore search – serious performance implications
• Number of results limited by Query.MaxItems setting (default is 100)

Context Node is the item you want to execute the query


from – it’s not part of the query

Escape item names with special characters such as hyphens


or spaces with # (e.g. #sitecore-cycling-holidays#) in the
Tools -> Xpath Builder Expression field
In Sitecore Rocks
Make sure you use straight quotes, not smart quotes – for
example, 'Bike'

8.0.0.3 www.sitecore.net/training
Uses for Sitecore Query
In a field’s Source field
• Query is supported in most list field types that accept a source
• Prefix with query: when using in source fields
• For Treelists selects the root item of the tree. Use a Parameterized Datasource in the
source field to restrict which items are shown / can be selected.

In API methods (but call only sparingly!)


For example:
Item[] items = Sitecore.Context.Database.SelectItems("/sitecore/content/*");
Item[] allDescendants = Sitecore.Context.Item.Axes.GetDescendants();

For any complex querying, instead use Sitecore search! (Module 8)


• Search uses an index
• Can use Sitecore’s LINQ API with Sitecore’s search
• Sitecore query is more likely to lead to performance issues
8.0.0.3 www.sitecore.net/training
Walkthrough– Topic 6.4.1 – Sitecore Query
(15 min)
Use Sitecore query in a source field
Walkthrough 6.4.A Set Related Articles field source

8.0.0.3 www.sitecore.net/training
Review – Sitecore Query
Q What will . return? Q Why shouldn’t you query the
 The context item. entire content tree?
 Expensive – particularly if you are
Q Name two axes available in iterating through all descendants
Sitecore query:
 ancestor-or-self::, parent::
Q Unless you are doing a very
simple query on a very limited
area of your Sitecore tree, what
should you use instead?
 Sitecore search

8.0.0.3 www.sitecore.net/training
Configuring the Experience Editor
Module 7

Data Source Restrictions


Parameters and Parameters Templates
Placeholder Restrictions
Advanced Experience Editor Configuration

Review the Experience Editor Recommended Practices Guide for Developers


http://sdn.sitecore.net/reference/sitecore%207/page%20editor%20recommended%20practices%20for%20developers.aspx

8.0.0.3 www.sitecore.net/training
Topic 7.1
Data Source Restrictions

By the end of this topic you will be able to:

Restrict the type of item that can be selected as a data source


Restrict the location from which an item can selected as a data source

8.0.0.3 www.sitecore.net/training
Data Source Location and Template Restrictions

Configured on component definition item


• Data Source Location limits selections to sub-items of the
indicated item location
o When you insert a component, the Select the Associated
Content dialog opens allowing selection of an item
• Data Source Template allows you to create new content
using that indicated template
o In addition, after setting the Data Source Template only
items that use that template can be selected from the
Select Existing Content->Select an existing content
item

8.0.0.3 www.sitecore.net/training
Demo 7.1 – Apply Restrictions
Demo objectives
• Apply data source restrictions using the Experience Editor
• Apply restrictions using Sitecore Rocks

8.0.0.3 www.sitecore.net/training
Exercise 7.1 – Data Source Restrictions
(20 min)
Datasource restrictions
Lab 7.1.A Set data source Location

Lab 7.1.B Add a component

Lab 7.1.C Set data source Template

Lab 7.1.D Add another component

8.0.0.3 www.sitecore.net/training
Review – Data Source Restrictions
Q What is the effect of setting a Q What happens if the Datasource
Datasource Location for a Location field is empty, but the
component? Datasource Template field is not?
 When adding the component in the  The dialog doesn’t open
Experience Editor, it will open the
Select the Associated Content dialog automatically, but when the author
and use the datasource location as the requests it, they see the whole tree
root of the tree with irrelevant items ghosted

Q What happens if the Datasource


Location and the Datasource
Template fields are both filled in?
 The Select the Associated Content
dialog opens and authors can create a
new content item using the template
specified

8.0.0.3 www.sitecore.net/training
Topic 7.2
Parameters and Parameters
Templates
By the end of this topic you will be able to:

Create and assign a Parameters Template


Describe the benefits to an author of using a Parameters Template

8.0.0.3 www.sitecore.net/training
Demo 7.2 – Using a Parameters Template
Demo objectives
• Create and assign a Parameters Template using Sitecore Rocks
• Show the result in the Experience Editor

8.0.0.3 www.sitecore.net/training
Specify Parameters Using a Parameters Template

Represent parameters as real fields instead of key/value pairs

VS.

• Base the template on the Standard Rendering Parameters template


• Build up templates using regular field types (such as Droplink)
• On the component definition item, assign the Parameters Template
• Per instance of a component, you can now choose a value for each parameter

8.0.0.3 www.sitecore.net/training
Exercise 7.2 – Parameters Templates
(50 min)

Parameters templates
Lab 7.2.A Create and assign a Parameters Template

Lab 7.2.B Use parameters in code to alter the sublayout display

8.0.0.3 www.sitecore.net/training
Review – Parameters and Parameters
Templates
Q What is the benefit of rendering Q If you want your component to
Parameters Templates to use this new Parameters
authors? Template, where do you assign
 Reduces errors since authors do not it?
need to correctly indicate parameter  On the component’s definition item in
names and authors can choose the Parameters Template field
predefined values from dropdowns

Q Which data template is used as a


base template for your
Parameters Template?
 Standard Rendering Parameters
template

8.0.0.3 www.sitecore.net/training
Topic 7.3
Placeholder Settings

By the end of this topic you will be able to:

Describe the purpose of a Placeholder Settings item


Explain Compatible Renderings

8.0.0.3 www.sitecore.net/training
Placeholder Settings Items
Placeholder Settings items are definition items for Placeholders

Placeholder Setting items…


• Make placeholders selectable in the Experience Editor
<sc:Placeholder Key="content" runat="server" />
• Used to set up restrictions
• Does not affect presentation details dialog in any interface
– only Add Component in the Experience Editor

Tip in student manual on how to


create a placeholder settings item

8.0.0.3 www.sitecore.net/training
Allowed Controls
Allowed Controls
• Configured on Placeholder Settings item
• Define which components can be added to that particular placeholder
• If none selected, everything is allowed

8.0.0.3 www.sitecore.net/training
Compatible Renderings
Compatible Renderings
• Configured on component definition items
• Must define each other as compatible
• Both must be allowed controls of any placeholder you want to add them to
• Consider whether components need to share parameters or data sources

We are so No, we are


compatible! not!

8.0.0.3 www.sitecore.net/training
Demo 7.3 – Allowed Controls / Compatible
Renderings
Demo objectives
• Use the Compatible Renderings button
• Assign compatible renderings
• Assign allowed controls

8.0.0.3 www.sitecore.net/training
Review – Placeholder Settings
Q When you add <sc:Placeholder Q Which Experience Editor mode
Key="myKey" runat="server" /> to supports adding components
your sublayout, what must you into placeholders?
do for the placeholder to be  Designing
selectable in the Experience
Editor? Q If a component is not in the
 Create a Placeholder Settings Allowed Controls list, can it be
definition item in Sitecore added into that placeholder
through the Experience Editor?
Q What else do these Placeholder  No
Settings items allow you to
specify for authors?
 Which components authors can insert
into a placeholder

8.0.0.3 www.sitecore.net/training
Review – Compatible Renderings / Allowed
Controls
Q What are compatible renderings? Q If a component is not in the
 Components that can be used in place allowed controls list, can it still
of another component be used as a compatible
rendering?
Q What two elements should you  No
keep in mind when setting up
compatible renderings?
 Both components need to be able to
accept the same Datasource and the
same Parameters

8.0.0.3 www.sitecore.net/training
Topic 7.4
Advanced Experience Editor
Configuration
By the end of this topic you will be able to:

Create a Custom Experience button


Create an Edit Frame

8.0.0.3 www.sitecore.net/training
Demo 7.4.1 – Custom Experience Buttons
Demo objectives
• Change an existing button in the floating toolbar of all components
• Add an additional Custom Experience button to the floating toolbar of the Gallery
component

8.0.0.3 www.sitecore.net/training
Custom Experience Buttons
Custom Experience buttons are a configurable
• Floating toolbar around fields and components

• Buttons list can be extended with Custom Experience buttons


• Lives in core database (/core/sitecore/content/Applications/WebEdit/Custom Experience
Buttons)
• Context aware – executes in context of either the Context Item or if the
component’s Data Source field is set, then it executes in the context of the Data
Source item

8.0.0.3 www.sitecore.net/training
Custom Experience Button Types and
Assignment
Customizing buttons
• Field Editor – Displays a field’s editor in a
pop-up window. This is useful for editing complex
fields in the Experience Editor, such as a Multilist field

• WebEdit – Indicates which code is triggered The Delete button will


by a button. For example, the default for
the Delete button is to fire execute this command
webedit:delete

Where are these buttons assigned?


• Component floating toolbar buttons are assigned
on the component definition item
• Field floating toolbar buttons are assigned on the
field definition item (child of the data template item)

8.0.0.3 www.sitecore.net/training
Edit Frames
Sitecore Control Pointing to List of Custom Experience Buttons

<sc:EditFrame Buttons="My Edit Frame" runat="server">


<!-- Markup Goes Here -->
<sc:EditFrame />

• Defined in code; surround any mark-up (for example, content from a Multilist field)
• Floating toolbar will appear in that location
• Buttons attribute points to folder of WebEdit/Field Edit buttons in Sitecore tree
• Defined in core database – /core/sitecore/content/Applications/WebEdit/Edit Frame Buttons
• Not aware of Datasource (but can be assigned using DataSource attribute)

8.0.0.3 www.sitecore.net/training
Demo 7.4.2 – Edit Frames
Demo objectives
• Create a field editor button
• Insert an Edit Frame into the Holiday Summary widget

8.0.0.3 www.sitecore.net/training
Exercise 7.4 – Edit Frame (20 min)
Custom Experience and Edit Frames
• Lab 7.4.A Add a Custom Experience button
• Lab 7.4.B Add an Edit Frame

8.0.0.3 www.sitecore.net/training
Review – Advanced Experience Editor
Configuration
Q Once Custom Experience Q What do Edit Frames do?
buttons are assigned, where do
 Surround an area on a page or
they show up? component and display buttons
 On a component / field and displayed allowing you to edit fields that would
in the Experience Editor not be normally editable in the
Experience Editor
Q Name two examples of custom
buttons: Q In which database do you create
 Field Editor and WebEdit buttons the Custom Experience buttons
and Edit Frames?
Q On what type of definition item
can you assign Custom  core
Experience buttons?
 A component definition item or a
field definition item

8.0.0.3 www.sitecore.net/training
Dealing with Your Data
Module 8

Item buckets
Search

8.0.0.3 www.sitecore.net/training
Item Buckets
Topic 8.1

By the end of this topic you will be able to:

Explain how buckets solve UI issues in large implementations


Create buckets and bucketable items
Configure bucket settings and facets
Use the buckets interface to search for and manage content

8.0.0.3 www.sitecore.net/training
The Scenario
Reliance on hierarchical data
• Not all data needs to be represented as a tree structure

Interface not designed for interacting with high volumes of data


• Author must manually locate item in tree based on path

In addition…

• Using API to interact with a large Sitecore tree is expensive and slow
• Developers forced to interact with hierarchical tree structure – not efficient when
dealing with large volumes of data (Topic 8.2)

8.0.0.3 www.sitecore.net/training
Demo 8.1.1 – Using Buckets as an Author
Demo objectives
• Use buckets to search for bookings
• Narrow down results using facets
• Edit and create items as normal
• Use plain-text search to search for a widget we know exists – for example, which-
bike. Use wildcards, replacements and exact phrases
• Change the results view to Gallery or GUID view
• Developers can replicate search mechanism in their code – query an index rather
than a tree

8.0.0.3 www.sitecore.net/training
What Is a Bucket?
• A bucket allows you to transform an item into a repository that stores other items
that are not displayed in the content tree
• Potential to store millions of items, which a tree structure would not support

Buckets search interface


‘Bookings’ item bucket with
hidden descendants within
traditional tree structure

• Friendly search UI for authors to manage a large number of items

8.0.0.3 www.sitecore.net/training
When to Use a Bucket
Advantages of Buckets
• Support for potentially millions of items that would not suit a tree structure and
slow down the UI – for example, products, repositories and orders
• Automatically organizes content items into a folder structure that improves
database retrieval performance
• Queries run against an index, ensuring high performance
• Find what you want quickly by using free text search, facets and search filters
Should I bucket?
Bucket if:
• You do not care about the structure of the data stored in the bucket
• You anticipate a large volume of items
• You would benefit from searching for items rather than locating them in the tree

8.0.0.3 www.sitecore.net/training
Demo 8.1.2 – Buckets and Bucketable Items
Demo objectives
• Turn reusable content into a bucket
• Make General Widget items bucketable
• Change bucket settings

8.0.0.3 www.sitecore.net/training
Creating a Bucket
Any item can become a bucket
• Items inside the bucket no longer have a parent/child relationship with any
semantic meaning
Convert selected item to a
o Organized into folders based on creation time (by default, this structure is hidden)
bucket
• Items in a bucket can still be created, edited and deleted by conventional means
• If you want to retain the parent/child relationship for items stored in a bucket (for
example, comments should always be children of a news article), then enable Lock
child relationship on the parent item’s template standard values

Bucket settings configured under: /sitecore/System/Settings/Buckets


• Facets
• Number of items in search results
• How results should open
8.0.0.3 www.sitecore.net/training
Making Items Bucketable
Items inside a bucket need to first be bucketable
• In practice, this means that the items will be hidden and restructured according to
configuration
o Note you can store regular content items in a bucket
o Will behave like regular content items – some bucket functionality will not apply
• You can either make individual items or templates bucketable
• Sync the bucket when you:
1) Make items or templates bucketable
2) Make items unbucketable

8.0.0.3 www.sitecore.net/training
Demo 8.1.3 – Facets
Demo objectives
• View a number of pre-existing facets created by developers

8.0.0.3 www.sitecore.net/training
Search Facets
Facets allow you to progressively narrow down your search results
• Configurable items in /Settings/Buckets/Facets
• Specify index field to facet on – for example, ‘size range’
may be a special computed index field that does not
exist in Sitecore
• If you facet on a Droplink, you would get a list of
GUIDs to facet on – not useful and would require custom
index configuration

8.0.0.3 www.sitecore.net/training
Exercise 8.1 – Create a Bucket and Make
Items Bucketable (20 min)
Create a bucket and makes items bucketable
Lab 8.1.A Turn the News Listing template into a bucket

Lab 8.1.B Make the News Article template bucketable

8.0.0.3 www.sitecore.net/training
Review – Item Buckets
Q Use a bucket when… Q What do facets allow you to do?
 You do not need a hierarchical item  Progressively apply filters (based on
structure and/or you have a large fields) to narrow down your result set
number of items

Q In order to store an item in a Q How do you create a bucket?


bucket, you must…  Select the item you want to turn into
a bucket and click the ‘Bucket’
 Make that item or the data template’s
standard values it is based on command on the Configure tab
bucketable

Q After making changes to the


bucketability of the items in a
bucket, you must…
 Sync the bucket

8.0.0.3 www.sitecore.net/training
Search
Topic 8.2

By the end of this topic you will be able to:

Search an index using a LINQ-based search API


Create a custom search result type
Configure what goes into your index and how it is stored
Facet on a set of results

8.0.0.3 www.sitecore.net/training
Simple Search
• Item buckets use Sitecore’s Search API
• You can leverage the same API to build search functionality for your website’s
front end

Get index by name

var index = ContentSearchManager.GetIndex("sitecore_web_index");


Create a search
using (var context = index.CreateSearchContext())
{
context
var queryable = context.GetQueryable<SearchResultItem>()
.Where(x => x["page heading"].Contains("bikes"));
}

Return an instance of Return type


IQueryable<T> and use standard
LINQ statements

8.0.0.3 www.sitecore.net/training
Demo 8.2.1 – Executing a Simple Search
Demo objectives
• Build a simple search – return all indexed items
• Search by the item’s Name property (Sitecore property)
• Search by item’s ‘Heading’ (developer-created property)

8.0.0.3 www.sitecore.net/training
Basic Index Configuration
Search works on an index that is external to Sitecore
• Configuration in /App_Config/Include/ (default and index-specific)
• Determine how items should be indexed

Uses provider model


• Identical LINQ layer
• Provider translates to work
with chosen search technology

Which one should I use?


• Sitecore ships with Lucene and Solr (Solr wraps Lucene and is more advanced)
• Use Solr to scale

8.0.0.3 www.sitecore.net/training
Demo 8.2.2 – Rebuilding the Index
Demo objectives
• Using the Sitecore Content Editor, expose the Developer toolbar
• Examine the rebuilding commands available
• View the default three indexes – one per database (master, core and web)
• Use the Rebuild button
• Learn how to rebuild without deleting the index folder
• Using the file system, examine the /Data/indexes folder to view each index’s folder

8.0.0.3 www.sitecore.net/training
LINQ Examples
The API implements the IQueryable<T> interface and supports most options
Standard LINQ Custom extensions
.Where .Boost (make this part more important)
.Any .Page (does skip/take)
.OrderBy .Between (exclude/include start and end ranges)
.Filter

Fuzzy search
queryable.Where(x => (x["page heading"].Like("Citecoar", 0.8));

Pagination
queryable.Page(1, 50);

8.0.0.3 www.sitecore.net/training
Custom Search Result Type
You create your own search result class
• Map Sitecore fields to index properties
• Your class will have an empty constructor and public properties
o Support for various property types, not just strings! (see the Student Manual)
• Can inherit from SearchResultItem for pre-mapped properties, such as
language

public class CustomResultItem : SearchResultItem


{
[IndexField("page heading")]
public string Heading { get; set; }
Heading index property is mapped
} to ‘page heading’ field

queryable.Where(x => (x.Heading.Like("Bike", 0.8));

Query using an index property


8.0.0.3 www.sitecore.net/training
Demo 8.2.3 – Paths, Pagination and Search
Result Types
Demo objectives
• Create a custom search type called CustomSearchResult - include a number of
different fields from base templates
• Inherit from Sitecore’s base SearchResultItem class
• Refactor search to query properties rather than strings
• Limit result set using .Paths
• Paginate results

8.0.0.3 www.sitecore.net/training
Returning a Result Set
A query returns an IQueryable<T>:
var query = context.GetQueryable<SearchResultItem>();

Use .GetResults() method to retrieve extra information


var results = context.GetQueryable<SearchResultItem>()

.GetResults();

int total = results.TotalSearchResults;

int count = results.Hits.Count(); //only this current page of results

var facets = results.Facets.Categories;

var list = results.Hits.Select(x => x.Document);

8.0.0.3 www.sitecore.net/training
Facets
Use .FacetOn() in your query, and GetResults() to retrieve the list of different
values.

var results = context.GetQueryable<SearchResultItem>(


.FacetOn(i => i.TemplateName)
.FacetOn(i => i.UpdatedBy)
.GetResults();

foreach (var facetCategory in results.Facets.Categories)


{
Response.Write(string.Format("<h1>{0}</h1>",facetCategory.Name)); // name
of field it is faceting on
foreach (var item in facetCategory.Values)
{
Response.Write(string.Format("{0} ({1})<br/>",
item.Name,item.AggregateCount));
}
}

Feed back into a .Filter()

8.0.0.3 www.sitecore.net/training
Demo 8.2.4 – GetResults() and Facets
Demo objectives
• Return the SearchResults object
• Set counts, hits and facets to variables and inspect

8.0.0.3 www.sitecore.net/training
Index Configuration
• By default, the majority of index configuration is shared between indexes and
stored in .DefaultIndexConfiguration.config per provider type
• For Lucene, that file is:

Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config

8.0.0.3 www.sitecore.net/training
Which Fields Should Be Indexed?
The more data you store, the larger the index
• Make sure you have configured your index to include only what you need by
controlling what is indexed
• Selectively exclude or selectively include fields and templates
<IndexAllFields>true</IndexAllFields> Index all except explicitly
excluded OR index nothing
• Settings can be overridden per index except included
<exclude hint="list:ExcludeTemplate" />
<include hint="list:IncludeTemplate" />
Include or exclude specific
<include hint="list:IncludeField" /> fields or items based on
<exclude hint="list:ExcludeField" /> specific templates

By default, the ExcludeField list has many standard fields that would not be valuable in an
index – for example, Allowed_controls and UpdatedBy.

8.0.0.3 www.sitecore.net/training
How Should Fields Be Indexed?
• How a field is indexed is determined by the field name (for example, the Page
Heading field) or its type (for example: Single-Line Text fields)
<fieldNames hint="raw:AddFieldByFieldName" />
<fieldTypes hint="raw:AddFieldByFieldTypeName" />
• The configuration files allow you to control what goes into
the index and how it is stored with increasing granularity
• Indexes can target all fields, individual types, or particular fields
• You can completely override the analyzer Standard field using
and write a new one if needed a particular analyzer

8.0.0.3 www.sitecore.net/training
Store or Index?
Indexes can store either the value of a field or a pointer to the field
• It’s useful to set the storageType to YES and store the field value if you want to
retrieve this value from the index instead of from the database

Stores the field


value in the index

Stores a pointer to
the field in the index

Only properties in the result object that map to stored field values will be populated
8.0.0.3 www.sitecore.net/training
Computed Fields
• Simple indexing is when a field value is put into an index without any processing
• Computed fields perform lookups and complex logic to determine what gets put
into the index and they do not have to match up directly to a Sitecore field

Example: Image size


You want to facet a list of articles by associated image size with potentially
hundreds of dimensions
A computed field can categorize images into image size of small, medium, or large
depending on specific size boundaries and then put these image size category
values into the index
Faceting on image size gives a distinct subset with a smaller number of results

• To create your own computed field, add an entry in the search configuration files:
<fields hint="raw:AddComputedIndexField" />

• Your computed field class must implement IComputedIndexField

8.0.0.3 www.sitecore.net/training
Exercise 8.2 – Output Content (60 min)
Refactor news listing
Lab 8.2.A Output news articles using Sitecore search API

8.0.0.3 www.sitecore.net/training
Review – Search (Part 1)
Q What defines how Sitecore items Q What is the name of Sitecore’s
should be indexed? default search result class?
 Index configuration files in  SearchResultItem
/App_Config/Include
Q When building your own search
Q Search is built using a provider result class, how do you account
model. What does this mean? for fields with spaces?
 You can plug in whatever search  Decorate with [IndexField("Page
provider you want Heading")]

Q What syntax do you use to query Q What method should you use to
an index? return a rich results object?
 LINQ  .GetResults();

8.0.0.3 www.sitecore.net/training
Review – Search (Part 2)
Q You can configure how fields get Q To store the number of comments
indexed by type or… for a news article, what type of
 Name field might you use?
Q You can include/exclude by  A computed field
individual field names or…
Q Why should you tune your index
 Item templates configuration and not index
Q Which attribute must be set to everything by default?
‘YES’ in order for values to be  Large, unwieldy index as your solution
stored in the index? grows
 storageType
Q Which two search providers does
Sitecore ship with?
 Lucene and Solr

8.0.0.3 www.sitecore.net/training
Extend
Sitecore Developer Portal
http://dev.sitecore.net

Search Scaling Guide


http://sdn.sitecore.net/Reference/Sitecore%207/Sitecore%20Search%20and%20
CMS%20Scaling%20Guide.aspx

Sitecore Technical Blog


http://www.sitecore.net/learn/blogs/technical-blogs.aspx

Sitecore Hangouts
http://www.youtube.com/user/SitecorePM

8.0.0.3 www.sitecore.net/training
Beyond the Developer
Environment
Module 9
Caching and Performance
Publishing
Installing and Scaling Sitecore
Team Development and the Development Environment
Basic Security
Workflow

8.0.0.3 www.sitecore.net/training
Caching and Performance
Topic 9.1
By the end of this topic you will be able to:

List the item cache layers


Name an action that clears HTML cache
Discuss prefetch cache
Discuss where you can clear all caches
State where cache settings are defined
Describe various caching options
Explain the purpose of Debug mode in the Experience Editor
8.0.0.3 www.sitecore.net/training
Item Cache
Item requested Item Data Prefetch Database

• When returned from the database, each caching level is regenerated with a more
complex object

• Defined in the <databases>section in web.config and Prefetch.config files

• There are more caches for XSL, standard values, paths, registry, etc.

8.0.0.3 www.sitecore.net/training
HTML Cache
For pages assembled from presentation components, each component can be cached

How to cache a component?


• Presentation Details
• Component Definition Item

Vary by allows you to store a different version


of the component based on for example, user, data source and so on

Statically bound components have cache settings set in the markup:


<sc:Sublayout Path="/layouts/Intro.ascx" Cacheable="true" VaryByData="true" runat="server"/>

8.0.0.3 www.sitecore.net/training
Clearing Cache
• The HTML cache is cleared by any form of publishing
o At the end of publishing, the HtmlCacheClearer clears
the cache. Found in the publish:end event in the
web.config
• Item and Data caches are cleared only for the items
published
Use ‘Clear all’ to
• Prefetch cache is populated when application starts clear all Sitecore
• When published items get requested for the 1st time, caches
they comes from the database

• View Cache admin page at


http://<yoursite>/sitecore/admin/cache.aspx
• View administrative information in Sitecore Rocks
by right-clicking the master database and clicking
Manage

8.0.0.3 www.sitecore.net/training
Demo 9.1.1 – Clearing Cache
Demo objective
• Navigate to http://traincore/sitecore/admin/cache.aspx
• Notice maximum cache sizes are listed in the right-hand column
• Demonstrate that caches can be cleared using Clear all button
• View cache information in Sitecore Rocks

8.0.0.3 www.sitecore.net/training
Cache Tuning and Configuration
Cache sizes are per database and per site
• Cache settings are defined in multiple places in the web.config
o For example, the default size of the standard value cache:

• You can disable all cache limits by setting DisableCacheSizeLimits to true:

• Items to be included in the prefetch cache are defined


in <database-specific>.config files in /App_Config/Prefetch Prefetch

8.0.0.3 www.sitecore.net/training
Demo 9.1.2 – Various Cache Settings
Demo objective
• Look at the various cache settings in the web.config:
o Default settings
o Cache sizes specified in the <databases> section
o Cache sizes specified on the <site> nodes or below the <sites> section

• Look at various cache configuration files in /App_Config/Prefetch


• Look at statistics page

8.0.0.3 www.sitecore.net/training
Experience Editor Debug Mode
Debug mode – runs against the WEB database
• View the profile, cache settings and HTML output of
individual components in the Experience Editor

Sitecore Glimpse (https://www.nuget.org/packages/Sitecore.Glimpse)


Profile table
Individual
component
summary

Top 3 items that take


the most time to render

Contextual debug
information
8.0.0.3 www.sitecore.net/training
Review – Caching and Performance
Q What are the three layers that Q Cache settings are defined in
the item cache mechanism have? what file?
 Item, Data and Prefetch  web.config
Q What operation clears the HTML Q Where can you define
cache? component HTML caching
 Publishing options?
 Component Definition Item, or in the
Q Which cache is populated when Presentation Details
the application starts?
 Prefetch cache
Q What mode in Experience Editor
shows profile, cache settings and
Q What is the path for the .aspx HTML output for individual
page that clears all cache? components?
 /Sitecore/admin/cache.aspx  Debug mode

8.0.0.3 www.sitecore.net/training
Publishing
Topic 9.2

By the end of this topic you will be able to:

Describe the different publish modes


Name the different ways for restricting publication
Discuss recommended practices for publishing strategies

8.0.0.3 www.sitecore.net/training
Types of Publishing
Three publishing modes
• Incremental – publishes changed items in a publishing queue
• Smart publish – compares master DB to web DB. If the RevisionID field is
different then the item gets copied across
• Republish – publishes all items
Each Sitecore interface has publishing options and each invokes
the appropriate publishing wizard
• Desktop’s main menu publish site options – incremental, smart and republish
• Experience Editor’s publish item options - smart and
re-publish (no incremental….why?)
• Content Editor’s publish site and publish item options

8.0.0.3 www.sitecore.net/training
Publishing Restrictions
Change publishing restrictions in the Content Editor
Options are applied to:
• Numbered Version of an item
Numbered
• The Item itself Item versions
• Targets

Targets

Note: Setting a publish restriction does not automatically publish your items, but simply sets the
restrictions. Publishing still needs to be triggered either manually or scheduled.

8.0.0.3 www.sitecore.net/training
Publishing Strategies
Options for scheduled publishing
• Publishing agent allows you to specify publishing interval and
type of publishing
• Dependent on the Sitecore scheduling agent
• Windows scheduled tasks can be used to run a custom service or page
• See blog for more information: https://www.sitecore.net/Learn/Blogs/Technical-
Blogs/Reinnovations/Posts/2014/03/Publishing-Improvements-in-7-2.aspx

Manual publishing may not be desired


• Full republish can slow performance
• If you do disable publishing for editors, use workflow’s publishing approval action*


* Workflows covered later

8.0.0.3 www.sitecore.net/training
Demo 9.2 – Publishing Options and Restrictions

Demo objective
• Set up publishing restrictions on an item

8.0.0.3 www.sitecore.net/training
Review - Publishing
Q Name the three publishing Q Publishing restrictions can be
modes applied to _____ , _____ and
 Incremental , smart and republish _____
 Numbered versions of items , the
item itself and targets

8.0.0.3 www.sitecore.net/training
Installing and Scaling
Topic 9.3

By the end of this topic you will be able to:

List multiple options for installing Sitecore


Discuss scaling options for the content management environment and the
xDB

Discuss how media is stored in Sitecore

8.0.0.3 www.sitecore.net/training
Options for Installing Sitecore
Download installation files at:
https://dev.sitecore.net/

Installation methods:
• Sitecore Installation Wizard
• Sitecore Instance Manager (SIM)
• Sitecore Rocks
• Manual install from a .zip archive

Refer to:
• Installation Guide
• Installation Troubleshooting Guide
• kb.sitecore.net for known issues

8.0.0.3 www.sitecore.net/training
Minimum Recommended
Basic servers
• Higher performance when databases are on their own specific server
• Start with separate CD and CM servers, with a shared dedicated database server

Databases
• CM server has access to core, master and web databases
• CD server(s) have access to the web database
o Access to either core or .NET membership database

xDB
• For example – start with separate collection, reporting and aggregation servers

8.0.0.3 www.sitecore.net/training
Storing Media
Media definition items are stored in the database
• Point to the corresponding database BLOB or file
• Located in the content tree
• Based on a template
oCan be extended
• Need to be published Templates are specific to media type:
image, docx, pdf, etc.

Media stored in the database as a BLOB


• Less fragile because files could be renamed or moved
• No file maintenance when moving
or syncing the environment – for example,
between developers, QA, production and so on

• Note: Media items are cached to the file system when rendered

8.0.0.3 www.sitecore.net/training
Developer Environment
Typically, all elements are on the same computer:
• Content management databases (core, master, web)
• Single Sitecore client (http://<mysite>/sitecore)
• xDB components

Not recommended for production environments.

8.0.0.3 www.sitecore.net/training
Running MongoDB
Sitecore 8 requires MongoDB running as a service
• Manual install or use Chocolatey.

GUI for MongoDB


• RoboMongo or MongoVUE are similar to SQL Management Studio

Changing MongoDB connection string creates new DB


• Stored in ConnectionStrings.config, default name is analytics
• Refer to Sitecore XP Installation Guide!

8.0.0.3 www.sitecore.net/training
Review – Installing and Scaling Sitecore
Q List some benefits of using Sitecore Q Name some features of Sitecore
Installer Instance Manager
 Checks prerequisites, correct DLLs, logs,
remove an existing installation  Packages, customize, extend,
reinstall & remove instances
Q Can you do a manual installation?
 Yes
Q What are the recommended servers
for an installation and which
databases are on each server for a
production environment?
 CM with core, master and web
 CD with core and web
 Separate DB server
 xDB with separate collection, reporting
and aggregation servers

8.0.0.3 www.sitecore.net/training
Team Development &
Development Environment
Topic 9.4
By the end of this topic you will be able to:

List the two development environments and their uses


Describe how to sync your files and content across environments
Name three tools used for serialization
Describe packages
Name the ASPX used to for upgrading Sitecore

8.0.0.3 www.sitecore.net/training
Setting Up a Solution
Development Benefits Drawbacks
model
Inside the web root: • Solution setup is quick • No clear separation of
• You are able to see your changes ownership
almost immediately • Difficult to transform
configuration files
• Development sites may
contain unnecessary artifacts
that may alter site behavior
inadvertently
Outside the web root: • Clear separation between solution • Changes to code typically
and Sitecore files need to be compiled and
• Ability to transform configuration copied to the web root
files within local developer • Initial solution setup can be
environments complex
• Better suited for multi-site
solutions
• Solutions can be bundled easily
for shipment
• Development sites remain clear of
code-behind files

8.0.0.3 www.sitecore.net/training
Patching the web.config
App_Config/Include config files merge into in-memory web.config
• Use specific .config files in the Include folder for each pipelines, events, etc
• You can configure where the nodes merge into the web.config (only works on
<sitecore> portion of the web.config)
• You can version control these include files, which makes Sitecore upgrades easy
• View the final, in-memory, merged web.config with Sitecore Rocks or
http://<yoursite>/sitecore/admin/showconfig.aspx

Tips
• .config files are applied to the web.config in alphabetical order
o Use prefixes and sub-folders if you would like to control the order
• See Include File Patching Facilities Guide for more information,
http://sdn.sitecore.net/upload/sitecore6/60/include_file_patching_facilities_sc6orlater-usletter.pdf

8.0.0.3 www.sitecore.net/training
Sitecore Packages
Moving Items and Files with Sitecore Packages
• Sitecore packages allow you to move item and file
changes from one server environment to another
• Sitecore distributes most additional software
modules as Sitecore packages
• With the Package Designer, you can manually
select items and files to add or you can add them
dynamically using a query
o You also configure conflict resolution (how the installer
behaves when existing items are found)

Sitecore Rocks
• Rock can create an Anti Package
• Rocks also allows you to selectively Add Dependencies…
8.0.0.3 www.sitecore.net/training
Demo 9.4.1 – Create a Package Using Sitecore
Rocks
Demo objective
• Create a package using Sitecore Rocks
• Create an anti package before installing

8.0.0.3 www.sitecore.net/training
Source Control and Serialization
• Sitecore items can be serialized into text files
then added to source control
• Working outside the web root makes it easier
to source control your custom code
• Serialization makes it easier to
synchronize changes across
local development environments Small teams can share
databases – Note: content
Methods of serializing: gets overwritten
• Serialization page - /sitecore/admin/serialization.aspx
• Post-save macro in Sitecore Rocks
• Content Editor’s Developer tab has serialization commands
• Serialization settings in the web.config
• Third party products like Hedgehog’s Team Development for Sitecore
or Unicorn

8.0.0.3 www.sitecore.net/training
Demo 9.4.2 – Serializing Items
Demo objective
• Show the serialization page at http://traincore/sitecore/admin/serialization.aspx
• Serialize an item on the Developer tab in the Content Editor
• Learn about Sitecore Rocks serialization commands

8.0.0.3 www.sitecore.net/training
Continuous Integration
Team Development for Sitecore (TDS) – by Hedgehog
• TDS serializes items to disk and stores references in a .csproj file
• Use a MSBuild project (or pass in additional config info) to deserialize into Sitecore
instance on CI server (Continuous Integration server)

Ship and Unicorn


• Two open-source options for serializing items and deploying

Razl (by Hedgehog) and Courier


• Two database comparison tools for synchronizing changes between environments
(rather than overwriting everything)

8.0.0.3 www.sitecore.net/training
Update Packages
How to upgrade Sitecore
• Important: do a database backup before upgrading
• Go to http://sdn.Sitecore.net
• Download the update package
• Go to http://<yoursite>/sitecore/admin/updateinstallationwizard.aspx

• Follow the wizard


• Go back to SDN for further configuration changes

8.0.0.3 www.sitecore.net/training
Exercise 9.4 – Installing Packages (5 min)
Install a package
• Lab 9.4.A Install a package using Sitecore Rocks

8.0.0.3 www.sitecore.net/training
Review – Team Development &
Development Environment
Q Name two development models Q What are Sitecore packages and
 Inside and outside the web root what do they contain?
Q Which one is best practice?  Zip files that contain items and code
files
 Development outside the web root
Q What are the options to source Q What is the name of the .aspx that
control your items? you go to when upgrading
 You can serialize your items for source Sitecore?
control with Sitecore Rocks or use a
product like TDS to do it.  /sitecore/admin/updateinstallationwizard
.aspx
Q What is the recommended way of
patching in changes to
web.config?
 Patch web.config with include files,
located under /App_Config/Include

8.0.0.3 www.sitecore.net/training
Basic Security
Topic 9.5
By the end of this topic you will be able to:

Name the application for defining access rights


Name the application for viewing the resolved access rights
List two entities that access rights can be assigned to
Describe the three permissions that are applied to access rights
Discuss how to override access rights

8.0.0.3 www.sitecore.net/training
Security Editor and Access Viewer
• Access the Security tools with the Sitecore Launchpad
or the Desktop interface

• Security Editor is used to define access rights


o Used for assigning permissions for both internal
Sitecore tool access and access by external website users
o Permissions: Allow, Deny or leave unspecified on each access right
Determined elsewhere,
such as by Inheritance
• Access Viewer is used to view the resulting access right
• Access rights are assigned to Users and Roles

8.0.0.3 www.sitecore.net/training
Roles Role
A
Role inheritance
• Access rights are cumulative
• Roles can belong to other roles Role
B
Role
C
Conflicting access rights
• Explicit deny will always take precedence
• Can be overridden at user level Write access to an item

Role Role
Client A B
• Sitecore comes with pre-defined roles
• Restricts what actions an editor can perform, for
example, Sitecore Client Publishing – allows
the user to publish

8.0.0.3 www.sitecore.net/training
Review - Security
Q Which application is used to view Q Name three permissions that are
the resolved access rights applied to access rights
 Access Viewer  Allow, deny and not specified = deny

Q You can assign access rights to


_____ and _____
 Users and roles
Q Can access be explicitly given to
a user to override the role access
right?
 Yes

8.0.0.3 www.sitecore.net/training
Workflows
Topic 9.6

By the end of this topic you will be able to:

Describe the purpose of a workflow


Discuss what a workflow consists of
State when an item is publishable
State three workflow recommendations

8.0.0.3 www.sitecore.net/training
Demo 9.6 – Using a Workflow as an Author
Demo objective
• Push an item through a workflow

8.0.0.3 www.sitecore.net/training
Workflow Name
What Is a Workflow?
Workflow State Name
Used for content approval to ensure
content readiness
• For example, if content needs to Item Name
be approved by different
members of the organization

Used for automatic numbered versioning


Workflow Commands
Consists of:
• Workflow States that an item moves through
• Each state can have Workflow Commands
and Workflow Actions
• Items are publishable when they are
in a Final Workflow State
o There can be multiple Final Workflow States

8.0.0.3 www.sitecore.net/training
Workflow
• Series of Workflow States that item versions must go through
• Versions move between states by Workflow Commands (or Workflow Actions)
• When a version is in a Final Workflow State and the item is edited again, a new
numbered version gets created

v2 v1
Awaiting v1
v1 Approval Approved
State State
Draft
State Optional
Approve Reject Action
Command Command
Auto Publish
Submit Action
Command Validation Pass
Action Validation

Optional Fail
action Validation v1
v2

8.0.0.3 www.sitecore.net/training
Review - Workflows
Q What are workflows used for? Q When is an item publishable?
 Content approval, versioning and  In the final state
tracking
Q When is a new numbered version
Q Items go through a series of ____ created?
 States  When an item’s version is in a final
workflow state and then
Q Each state can contain certain subsequently is edited by a non-
_____ and _______ Administrator.
 Commands and actions

8.0.0.3 www.sitecore.net/training
Marketing Functionality
Module 10

Introduction to the Experience Platform


Engagement Values and Goals
Multivariate Testing
Profiling and Personalization

8.0.0.3 www.sitecore.net/training
Introduction to the
Experience Platform
Topic 10.1
By the end of this topic you will be able to:

State the main features of the Experience Platform (XP)


Explain how data is collected
Describe what a contact is
View the Dashboard and Engagement Analytics reports

8.0.0.3 www.sitecore.net/training
Marketing Functionality
Collect, measure, report, personalize and optimize
• Collect visitor behavior, geographical location, visit origin, etc.
• Measure the effectiveness of your site by tracking visitor interaction
• Report information about the site, campaigns, individual visitors, etc.
• Personalize content to adapt it to your visitors’ interest
• Optimize your website using tests

8.0.0.3 www.sitecore.net/training
What Data Is Collected?
• Where are the visitors from? Country, City, Region, Business name
• How do the visitors arrive on the site? Pay-per-click ad, social campaign,
referrer, keyword search, etc.
• Are they known visitors? Have they visited the site before?
• What pages are they visiting? What do they do on those pages? How long
do they spend on each page?
• Are the visitors providing us any data? Form filling, social login
integration?

Sitecore collects all of this


information concerning
each visitor and each visit

8.0.0.3 www.sitecore.net/training
How Is Analytical Data Collected?
Experience Database (xDB)

• Non-SQL database, allowing for flexible scaling

• Collects information resulting from visits to the site

• Supports sharding, multiple collection centers & distributed geographical locations

• Allows for cloud and on-premise functionality

8.0.0.3 www.sitecore.net/training
Data Aggregation
All this data needs to be aggregated for optimal reporting
A customizable aggregation pipeline exists
This can run on dedicated servers
Stores data in a SQL Server reporting database

xDB (Collections) xDB (Reporting)

8.0.0.3 www.sitecore.net/training
Contacts
Sitecore helps you know your visitors better
You can:
• View all information about a visitor in their Contact Record
• See all contacts in the Experience Profile
• Create groups of contacts in the List Manager to target them in campaigns

8.0.0.3 www.sitecore.net/training
Reporting
Experience Profile
• Complete view of individual contacts
• Drill down to information of any interaction

Experience Analytics
• Aggregate data over time
• Audience: Who are they? Where are they from?
• Acquisition: How did they arrive to the site?
• Behavior: What did they view on the site?
• Conversions: Which desirable actions
did they perform?

Path Analyzer & Page Analyzer


• View the sequence of pages contacts follow during interactions

8.0.0.3 www.sitecore.net/training
Demo 10.1 – The Experience Profile
Your visitors are Contacts

Demo objectives
• Use the Experience Profile to see information about the latest visitors
• Show the type of information Sitecore captured during a contact interaction

8.0.0.3 www.sitecore.net/training
Review – Introduction to the Experience
Platform
Q What tool will show you all Q How does Sitecore store visitor
contacts that have been to your data?
site?  Data is collected in a MongoDB
 Experience Profile collection database.

 That information is aggregated and


stored in a SQL Server database
optimized for reporting

8.0.0.3 www.sitecore.net/training
Engagement Value and Goals
Topic 10.2

By the end of this topic you will be able to:

Describe the difference between value and traffic


Create goals and assign them

8.0.0.3 www.sitecore.net/training
Value vs. Traffic
• Traffic figures (number of hits) are not a true representation of how much a visitor is
engaged with your site – for example, visiting the homepage (low engagement) versus
booking a holiday (high engagement)
• A site that encourages engagement is more effective – for example, 10,000 visits and 10
bookings versus 1000 visits and 100 bookings
• Sitecore introduces the concept of engagement value
o A number that represents how much
quality time a user spent on your website
• The more valuable actions a customer performs on your site, the higher their
engagement value
(for example, request a brochure, fill in the contact form, make booking)

8.0.0.3 www.sitecore.net/training
Engagement Value Is Measured Using Goals
• Goals are defined in the Marketing value
Center and have a value associated
with them
• A goal’s value depends on its value
to the business – for example, a
holiday booking is worth more to the
business than a brochure request
• Goals are either assigned to pages
(for example, the contact form
thank-you page) or
• Triggered programmatically – when
a visitor triggers a goal, the
engagement value for that visit Assign a goal
increases to a page

8.0.0.3 www.sitecore.net/training
Demo 10.2 – Create and Assign a Goal
The Sitecore Cycling Holiday’s site sells cycling holidays, so the
most important task a visitor can perform is booking a holiday

Demo objectives
• Use the Marketing Center to create a goal called Booked a holiday
• Give it a value of 50
• Assign this goal to the booking confirmation page (the book-holiday/thank-you item)

8.0.0.3 www.sitecore.net/training
Review – Engagement Value and Goals
Q Engagement is measured using… Q Goals can be assigned to
 Goals specific items and/or…
 They can be triggered
programmatically

8.0.0.3 www.sitecore.net/training
Multivariate Testing
Topic 10.3

By the end of this topic you will be able to:

Describe what can be tested


Explain the requirements to enable testing
Set up and run multivariate tests

8.0.0.3 www.sitecore.net/training
Testing
• Allows you to test the effectiveness of your site by seeing…
o Which variation resulted in greater overall engagement value
o The effect on individual goals
• Is Integrated as part of workflow
o Whenever an author makes a change, content or presentation, they have the
opportunity to create a test
• Tests can stop automatically when there is enough certainty that one of the
variations provides better results
o Specific goals or overall engagement value
Start test after a
change

8.0.0.3 www.sitecore.net/training
What Can You Test?
• Change your content – test different versions of your items
• Modify your presentation – change components or data sources
• Swap the entire page – test between multiple different items

8.0.0.3 www.sitecore.net/training
How to Let Your Authors Test?
• Use workflows to add a Launch Create Test Dialog Workflow Action
(Remember workflow does not work as expected if you are an admin)
• Components should be configured to accept data sources
• Make sure the Experience Editor is configured correctly

8.0.0.3 www.sitecore.net/training
Review – Multivariate Testing
Q What is the purpose of testing? Q What to do to make sure your
 Establish which content or authors can use the testing
components makes your visitors react functionality?
more favorably  Add ‘Launch Create Test Dialog’ to
workflow
Q When can authors start a test?
 As part of workflow– whenever they  Make sure the Experience Editor
have made a change on a page works and is configured correctly

 Ensure components that should be


Q What can be tested? tested are configured to accept data
 Content, components or entire pages sources

8.0.0.3 www.sitecore.net/training
Profiling and Personalization
Topic 10.4

By the end of this topic you will be able to:

Set up personalization on a component


Describe a profile card in terms of how it aggregates profile keys within a
dimension

Assign profile cards to items

8.0.0.3 www.sitecore.net/training
Personalization
Content and component type can be personalized
Change a component’s data source, component type, or hide the component

You can personalize based on:


• Goals and events triggered
• The visitor’s accrued profile points
• The visitor’s location, and more

Rule determining when


to change data source

It is important that you have componentized and made good use of data sources –
otherwise personalization will not work

8.0.0.3 www.sitecore.net/training
Demo 10.4 – Personalize Based on Page Visited

Demo objective
• Set up a personalization rule that changes a homepage General Widget
component data source to Expert Holidays if Battle of the Hills has been visited

8.0.0.3 www.sitecore.net/training
Profiling Content Items
Score items based on the audience you are targeting
Business stakeholders design profiling taxonomy (configuration done by developers)

Authors assign points to items in different categories based on audience being targeted
(or bulk-assign using Profile Cards)

Visitors accrue points based on the content they visit and build up a profile

Content can be personalized based on browsing habits

Profile individual
content items

8.0.0.3 www.sitecore.net/training
Review – Profiling and Personalization
Q What does it mean to profile Q How does componentization and
content? use of data sources support
 Assigning points in certain categories personalization?
based on the audience that a content  As a visitor navigates around the site,
item is aimed at components can be added / hidden or
their data changed to match a
particular pattern card or profile key
score

8.0.0.3 www.sitecore.net/training
Certification

Exam and Evaluation

8.0.0.3 www.sitecore.net/training
Sitecore Certification Center Exam
The exam has 40 questions
• Open Book!
• Pass or No pass
• 28 correct answers (70%) to pass
• Multiple choice with 3 options
• Only 1 correct answer
• 60 minutes
• Retake possible

No going back!
• You cannot change an
answer once you click
Next >

8.0.0.3 www.sitecore.net/training
Course Evaluation
• 11 quick Questions
with space for your
valuable comments!

• Evaluations are
anonymous

• We value your
opinions, so please
share them with us!

8.0.0.3 www.sitecore.net/training
Exam
Go to this URL and log into the test with the
username and password shown

URL: http://scc.sitecore.net
Username: xxx_WND80
Password: xxxxx

Then log in in with your SDN credentials

8.0.0.3 www.sitecore.net/training
Bonus Topics
Module 11
Branch Templates
Other Item and Template Properties
Pipelines and Events
Rules
Placeholder Overrides

8.0.0.3 www.sitecore.net/training
Branch templates
Topic 11.1

By the end of this topic you will be able to:

Enable authors to create a structure with multiple items in one click

8.0.0.3 www.sitecore.net/training
Branch Templates
• Allow users to insert a number of predefined sets of items at once
• A branch template consist of a branch item with several child items
• All these items will be created during an insert operation

Trip Details

8.0.0.3 www.sitecore.net/training
Demo 11.1 – Creating a Branch Template
Demo objectives
• Create a branch template in the Template Manager

8.0.0.3 www.sitecore.net/training
Review – Branch Templates
Q What function do branch
templates have?
 Allow authors to create an item and a
list of child items in one click

8.0.0.3 www.sitecore.net/training
Topic 11.2
Other Item and Template Properties

By the end of this topic you will be able to:

Describe where to set field sorting


Discuss where to set helper text

8.0.0.3 www.sitecore.net/training
Demo 11.2.2 – Helping Authors
Demo objectives
• Sort fields
• Add help text to fields
• Change the title of a field to something more intuitive

8.0.0.3 www.sitecore.net/training
Sort Order
Change __Sortorder field on field definition item, or use Template
Field Sorter tool
Right-click inside Editor
Pane and enable Standard
Fields…

… or use the sorting tool (Tasks >


Template Field Sorter)

*Must be done on standard values or on an item –


either way, it affects the template’s fields

8.0.0.3 www.sitecore.net/training
Help Text
Use Set Help option in
Sitecore Rocks
Add helper text to field names
for authors With help text

Without help text

Field
definition
item

8.0.0.3 www.sitecore.net/training
Title Field
• Change the field name that is displayed to authors
• For developers the field name stays the same

Field
definition
item
Title field

What the
user sees

8.0.0.3 www.sitecore.net/training
Exercise 11.2 – Working with Versions, Sorting &
Helping Authors (35 min)
In this exercise you will be working with language and numbered
versions, optional labs for helping authors

Lab 11.2.A Add a new language and some numbered versions


Lab 11.2.B Field source
Lab 11.2.C Change the sorting order
Lab 11.2.D Help fields
Lab 11.2.E Title field Language
and number
versions

Field source

8.0.0.3 www.sitecore.net/training
Review – Other Item and Template
Properties
Q Items exist in a ___ and ___version. Q What is the field called where you
 Language and numbered set up field sorting?
 Sortorder
Q What does unversioned for field
versioning mean? Q Where is this field found?
 Single value per language
 Standard fields
Q What does shared for field
versioning mean? Q On what type of item do you do
field sorting?
 Single value for all numbered versions in
all languages  On the field definition item
Q What is the default field Q Name two fields that you can use
versioning? to help a multi-lingual audience
 Versioned – different values for all  Long description and short description
languages and numbers fields - also part of the standard fields

8.0.0.3 www.sitecore.net/training
Pipelines and Events
Topic 11.3
By the end of this topic you will be able to:

Define pipelines and events


Describe where to configure pipelines and events
Describe the type format for the <processor />
Name the most important pipeline
Name the method that all processors implement
State which files are used to patch your processor into the pipeline
List three options for creating pipelines
8.0.0.3 www.sitecore.net/training
Introduction to Pipelines
Pipelines break down complex operations into multiple, configurable steps

Pipelines are defined in /configuration/sitecore/pipelines in the web.config

Pipelines are defined in 2 places


<processors /> - UI processes (e.g. uiCloneItems, uiDeleteItems)

<pipelines /> - system processes (e.g. httpRequest Pipeline)

One of the most important pipelines is the httpRequest Pipeline, which is invoked by
the httpApplication.BeginRequest event

The httpRequest Pipeline performs tasks such as resolving sites and language

Each of the steps is specified as a separate <processor /> within the pipeline

8.0.0.3 www.sitecore.net/training
Processor
Each step in a pipeline is a <processor /> with a type in the format of Namespace,
Assembly

Steps are executed in the order specified in the web.config

All processors
Implement the Process() method

Accept arguments that are particular to the pipeline they serve

InsertRenderingsProcessor

8.0.0.3 www.sitecore.net/training
Creating Pipelines Option 1
There are 3 options for using pipelines to customize Sitecore behavior

Option 1: Add processors to existing pipelines


Locate the processor that you want to extend – for example, insertRenderings

Decide where your step fits in – for example, if your processor modifies the parameters on a
rendering, you want it to appear after the renderings have been added to the page – such as
after: Sitecore.Pipelines.InsertRenderings.Processors.AddRenderings

Use include files to patch your processor into the pipeline

Determine whether processors in the pipeline inherit from an abstract class – in the case of the
insertRenderings pipeline, all processors inherit from the abstract
InsertRenderingsProcessor class

Decide what args the Process() accepts – in this case InsertRenderingsArgs

Write your pipeline code in the Process() method

8.0.0.3 www.sitecore.net/training
Creating Pipelines Options 2 & 3
Option 2: Override and extend existing processors
Instead of adding extra steps to a pipeline, replace the processor with your own by deleting
the existing processor, using include files and patching in your own

By either:

Inheriting from that processor giving you access to the methods in the original
AddRenderings

Writing a custom processor can involve copying all or some of processor’s code

Note: Pipelines may need updating if Sitecore has been upgraded

Option 3: Create new pipelines that you call from your code

8.0.0.3 www.sitecore.net/training
Introduction to Events
An event is something that happens that you can respond to

For example an item being saved


or a version being added etc.

You can subscribe to events

Events can be extended and overridden with your own event handlers, or you can write
your own

Events are defined in /configuration/sitecore/events in the web.config

Each event can have any number of <handler /> nodes that specify a type and method:

8.0.0.3 www.sitecore.net/training
Subscribing to Events and Using Event Handlers
Create a class with a method that accepts a sender object and EventArgs
Depending on what event the handler subscribes to, the type of the EventArgs changes –
in this example it is a SitecoreEventArgs
SDN – Using Events

Event handler
that is executed
when an item is
saved

Add your handler to the appropriate event, specifying the namespace, assembly, and
method:

8.0.0.3 www.sitecore.net/training
When Would You Use Pipelines or Events?
If a task is not needed in realtime, Sitecore Jobs can be used to perform
maintenance rather than packing those tasks in the save or publisher pipeline
slowing down the process

Is it a pipeline or an event…
Intercept requests and authenticate the user against an external service PIPELINE

When a news item is saved, automatically move it into to the appropriate year /
month / day folder structure EVENT

When publishing begins EVENT

Change how Sitecore resolves a language PIPELINE

Change the way Sitecore resolves URLs PIPELINE

8.0.0.3 www.sitecore.net/training
Review – Pipelines and Events
Q What are pipelines? Q What method do all processors
 Break down operations into multiple implement?
configurable steps  Process()
Q Where are pipelines defined? Q What are the three options for
 In the web.config as <processors /> creating pipelines
and <pipelines />  Add processor to existing pipeline
Q In what folder on the file system  Override and extend existing
do you store your pipeline processors
configuration files?
 Create new pipelines steps
 The Include folder

8.0.0.3 www.sitecore.net/training
Review – Pipelines and Events
Q Give an example of an event that
you can subscribe to
 Item saved / created / updated /
deleted / moved / renamed / and so on

Q How do you subscribe to events?


 Using event handlers
Q Where are events defined?
 In the web.config

8.0.0.3 www.sitecore.net/training
Rules
Topic 11.4

By the end of this topic you will be able to:

Define a rule
Name the two fields that define a rule

8.0.0.3 www.sitecore.net/training
Sitecore Rules Engine & Rules
A rule consists of conditions and actions

If a specific condition evaluates to true then


a certain action gets triggered – just like an
if statement

Conditional renderings use the rules engine for personalization. A rule example: if a user has 5
value points, then change the data source of a component

Rules are part of the core Sitecore functionality and can be used everywhere
for example, conditional insert options (if a user is ____, show ____)

8.0.0.3 www.sitecore.net/training
How Does a Rule Work for Authors?
Conditions and actions
User selects any number of conditions and actions

Evaluated in succession

If end result is true, actions are executed

8.0.0.3 www.sitecore.net/training
Demo 11.4 – Implementation of Insert Options
Rule
Demo objectives
• Create an insert options rule that adds Simple Link as an insert option to any item
whose name equals Links

8.0.0.3 www.sitecore.net/training
Review – Rules
Q A rule consists of a ______ and Q In what other scenarios can rules
______ be used, besides personalization?
 Conditions and actions  For example, Insert Options

Q What should the final result be


for a condition for the action to
be executed?
 True

8.0.0.3 www.sitecore.net/training
Topic 11.5 Placeholder Overrides

By the end of this topic you will be able to:

Override a placeholder setting for a particular item

8.0.0.3 www.sitecore.net/training
Demo 11.5 – Create Placeholder Setting Override

Demo objectives
• Create a new placeholder in the mark-up
• Create a placeholder setting override

8.0.0.3 www.sitecore.net/training
What Are Placeholder Overrides Used for?
You may want to keep the same placeholder on various pages throughout your website.
But if you want to allow different controls into that placeholder will depend on which item
the placeholder is on.

Placeholders have an Editable checkbox as do components


Make the placeholder not editable – restricting authors in Experience Editor Design mode

For example, the Placeholder Setting for the gallerycontainer is set up to allow Banner
and Gallery components. You may want to make that placeholder not editable on the
News Article page. To do this, you must create a placeholder override (for instance,
gallerycontainer-newsarticle). This placeholder targets the same placeholder tag, but has
different settings.

Uncheck the
Editable
checkbox

8.0.0.3 www.sitecore.net/training
How to Override a Placeholder Setting
Overriding the placeholder settings for a placeholder in the
Experience Editor
Select your placeholder and click Edit the placeholder
settings

Click Create New Settings

Give the placeholder a name and allowed


controls

Now the author sees the new placeholder


in the Experience Editor for that particular item

8.0.0.3 www.sitecore.net/training
In the Content Editor
You get a placeholder settings item with a
new placeholder key

content-with-gallery settings
used in place of content in
item presentation details

8.0.0.3 www.sitecore.net/training
Where to Override Placeholder Settings
On the instance of an item
Create a setting for one page to prevent authors changing components, for example, the
gallery on the Cycling Holidays homepage

On the standard values


If you want the placeholder override to appear on all items instead of just once, you can
override placeholders on the template standard values using the Layout Presentation
Details dialog

8.0.0.3 www.sitecore.net/training
Exercise 11.5 – Create Placeholder Setting
Override (20 min )

Create a placeholder setting override


Lab 11.5.A Override a placeholder setting in Page Editor

Lab 11.5.B Copy the placeholder override to the standard values

8.0.0.3 www.sitecore.net/training
Review – Placeholder Overrides
Q Why would you override a
placeholder settings item?
 If you have a particular page that
needs to display different allowed
controls in a certain placeholder – you
would override the placeholder
settings item with the required
allowed controls

8.0.0.3 www.sitecore.net/training

Vous aimerez peut-être aussi