WND CourseManual_v7.2.0.1x Course Manual V7.2.0.1

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 261 [warning: Documents this large are best viewed by clicking the View PDF Link!]

SitecoreTraining
Sitecore®ExperiencePlatform™7.2
CourseManual
WebsiteDevelopmentfor.NETDevelopers
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 2
Welcome
Thankyouforattendingthis4daycoursewhichteachesparticipantshowtoworkasaneffective.NETDeveloper
onaSitecoreproject.
Thiscourseisintendedfor.NETwebdeveloperswithadvancedC#skillswhoarenewtotheSitecoreAPIand
wishtodevelopwebsitesusingSitecoreRecommendedPractices.
Foreword
TheoriginalgoalofthiscoursewasnotonlytoteachdevelopersthefundamentalsofbuildingaSitecoresite,but
alsotodosoinaccordancewithrecommendedpractices.Wewantedtogivedevelopersthetoolstosupportboth
visitorandbusinessuserneeds,bybuildingsolutionsthattakefulladvantageoftheplatform’sfeaturesandcan
scaletomeetthedemandsofthebusiness.Inthisrelease,wehavestreamlinedthefundamentalsand
reemphasizedtheimportanceofunderstandingwhattheframeworkhastooffer,andhowtogetthemostout
SitecoreasanExperiencePlatform.
MartinaWelander,September2014,BristolUK
MartinaWelander
LedDevelopmentProject
MartinaHeleneWelanderisaTechnicalConsulting
EngineeratSitecoreand(strangely)aHistorical
StudiesgraduatefromBristolUniversity.AtSitecore,
shehasworkedtirelesslytocreateandcomplete
dozensofprojectsthathavehelpeddefinetheway
usersseeSitecoreandultimately,howourclientssee
theirownbusinessesandmarketingstrategies.
Martinaisatechnicalchameleon,withvastandvaried
knowledgeofSitecore,C#,frontenddevelopment,
anduserexperience.SheblogsforSitecoreat
http://www.sitecore.net/Learn/Blogs/Technical
Blogs/MartinaWelanderSitecoreBlog.aspx,and
initiatedaTwitteraccountforSitecoreEducation
Servicesathttps://twitter.com/mastersitecore.
MartinaalsoupdatesherownTwitterfeedwithher
trademarkhumourat
https://twitter.com/mhwelander.
Inhersparetime,MartinaslayszombiesinMinecraft,
makestimelyuseofÆtherizeinMagictheGathering,
bakes,runs,andplaysplaybypostRPGs.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 3
MichelleWhite
ProvidedDomainExpertise
GreatlyInfluencedCourseRestructuring
MichelleWhiteisaTechnicalArchitectandInstructor
whojoinedtheSitecoreUSAteaminearly2012.She
enjoyssharingSitecoreknowledgewithmany
differentaudiencegroups.Michelle’sexperiencesas
anITconsultant,andapassionateinstructorsincethe
early90’s,extendacrossmultipleplatformsand
applications,includingMicrosoft,resultinginmultiple
areasofexpertise,MCTs,andMasterMicrosoft
Instructorachievements.
MichelleenjoysriddingMiddleEarth(LOTRO)oforcs,
football,gardening,reading,andisanaccomplished
artist.
SenGupta
ProvidedDomainExpertise
GreatlyInfluencedCourseRestructuring
AtousaMemarpouri
ProvidedCreativeDirection
DroveOverallLookandFeel
SenGuptahasbeeninnovatingatSitecoresince2011.
AcertifiedMicrosofttrainer,hehasbeendeveloping
softwareandtrainingonMicrosofttechnologiesfor
10+years.DespiteSen’ssincerebeliefthatWNDtruly
enablesdeveloperswithallthatitofferstoday,his
obsessiontocontinuallyimproveitwillnotrest.When
heisnotworkinghardforSitecoreSenlovestocook
andracehislatestprizedpossessionaKTMDuke390.
Atousacomesfromacreativebackgroundandhas
yearsofhandsonexperiencewithContent
ManagementSystems.Herfavouritehobbiesinclude
reading,cookingandkeepingfitbyrunningabout
afterherthreebelovedpets.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 4
DanZhang
BuiltCourseApplication
WendyLawn
TestedLabs
DanZhangisatechiewithapassionforenabling
others.Danhasoverfiveyearsofexperienceasaweb
developer,withanumberofspecialitiesincluding
HTML,SQL,Javascript,C#etc.Sheisalsoan
accomplishedacademicwithaBachelor’sdegreein
SoftwareEngineering,andaMaster’sdegreeinIT
withSecurityfromUniversityofBristol.
Shelovestravel,designandpaintinginherspare
time.
Wendyhasover10yearsofexperienceinthefield,
including8yearsdevelopingcomputerbasedtraining
formilitarycontracts.Sheisdrivenbyapassionfor
gooddesign,technologyandthefutureoflearning
technologies.
SusanMarenco
CopyEditedCourse
SupportedFormattingEfforts
ProvidedFinalPolish
Forthelast15years,SusanMarencohasworkedasa
writerandeditorforMicrosoftDevelopmentCentre
Copenhagen,EgmontPublishing,UNICEFandmany
othercompanies.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 5
CourseParticipantsPrerequisites
InadditiontoITprofessionalskills,learnersshouldalsohaveexperiencein:
SitecoreusertoolscomprisingContentEditor,PageEditorandDesktopandSitecoreusertasks
includingPublishingandWorkflows(SitecoreFoundationsPreLearningVideo).
Programmingusing.NetWebFormsandC#.
WorkingwithMicrosoftVisualStudio2012orhigher.
WorkingandinteractingwithMicrosoftSQLServer.
SitecoreCertifiedInstructors
YourinstructorisaSitecoretechnicalandinstructionalexpertwhohasmetrigorousstandardstobeableto
deliveryourcourse.
SitecoreCertification
SitecorecertificationisavaluablecredentialthatdemonstratesyourskillsintheSitecoretechnology.Toearn
certificationyoumustcompleteandpasstheexamattheendofyourtraining.Youwillneedtoregisteronour
https://sdn.sitecore.net,theSitecoreSDNportal,tocompletetheassessment.
PostCourseAssessment
Sitecorevaluesyouropinionsowewouldappreciateitifyouwouldfillinanassessmentquestionnaireattheend
ofyourtraining.
Iconsusedinthismanual
Important
Importantinformationorwarnings.Readcarefully.
Recommended/BestPractices
Recommendedpracticenotice.Adherewheneverpossible
Tip/Note
Akeyfeaturethatishighlighted.
Demo/Walkthrough
Providelinksandreferencestofurthermaterialrelatingtoexerciseinthemodule.
Apply
Provideexercisesrelatingtothematerialinthemodule.
KnowledgeCheck
Masterthecoveredconceptsandterminology.

CopyrightNotice:
Informationinthisdocumentissubjecttochangewithoutnotice.Allexamplecompanies,products,domainnames,emailaddresses,logosandpeopleare
fictitious.NopartofthisdocumentmaybecopiedortransmittedelectronicallywiththepriorapprovalofSitecore.Sitecorehasnoresponsibilityforanylinksto
externalwebsites
p
rovidedinthisdocument.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 6
Contents
SitecoreOverview..........................................................8
CourseOverview...........................................................................................................9
WhatIsSitecore?........................................................................................................11
SitecorefromanAuthor’sPerspective........................................................................15
SitecorefromaDeveloper’sPerspective.....................................................................20
DefiningData...............................................................23
CreatingDataTemplates............................................................................................24
DataTemplateInheritance.........................................................................................30
StandardValues..........................................................................................................39
InsertOptions.............................................................................................................44
SummaryandOptionalLab........................................................................................46
Presentation................................................................48
PresentationIsDynamicandModular.........................................................................49
PreparingtoBuild.......................................................................................................51
CreatingaLayout........................................................................................................57
CreatingComponents.................................................................................................63
DynamicBinding.........................................................................................................67
OutputtingContent....................................................................................................74
SummaryandOptionalLab........................................................................................76
SitecoreAPI.................................................................78
BasicAPIConceptsandRetrievingItems....................................................................79
ItemLinks...................................................................................................................85
Creating,Modifying,andDeletingItems.....................................................................89
WorkingwithComplexFields......................................................................................97
AdvancedPresentationConcepts................................105
ReusableContent......................................................................................................106
LayoutDeltas............................................................................................................115
RealWorldSolutions...................................................117
FamiliarConcepts.....................................................................................................118
DealingwithLargerSites..........................................................................................130
SitecoreQuery..........................................................................................................133
ConfiguringthePageEditor.........................................137
DatasourceRestrictions............................................................................................138
ParametersandParameterTemplates......................................................................141
PlaceholderRestrictions............................................................................................144
AdvancedPageEditorConfiguration........................................................................147

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 7
DealingwithYourData................................................153
ItemBuckets.............................................................................................................154
Search.......................................................................................................................161
RecommendedPractices..............................................173
WorkingwithMedia..................................................................................................174
CachingandPerformance.........................................................................................176
Publishing.................................................................................................................181
InstallingandScalingSitecore...................................................................................185
TeamDevelopmentandtheDevelopmentEnvironment...........................................189
HowtoDealwithDeployment..................................................................................195
BasicSecurity............................................................................................................197
Workflow..................................................................................................................199
MarketingFunctionality..............................................202
IntroductiontotheCustomerExperiencePlatform(XP)............................................203
EngagementValueandGoals...................................................................................205
ProfilingandPersonalization....................................................................................211
OptionalTopics..........................................................214
BranchTemplates.....................................................................................................215
OtherItemandTemplateProperties.........................................................................217
PipelinesandEvents.................................................................................................227
Rules.........................................................................................................................231
PlaceholderOverrides...............................................................................................233
Review......................................................................239

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 8
SitecoreOverview
Contents:
CourseOverview
WhatIsSitecore?
SitecorefromanAuthor’sPerspective
SitecorefromaDeveloper’sPerspective

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 9
CourseOverview
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describetheobjectivesofthiscourse.
Content
ObjectivesforThisCourse
CourseFormat
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 10
ModuleOverviews

Module1SitecoreOverview
Courseoverview
WhatisSitecore?
Sitecorefromanauthor’sperspective
Sitecorefromadeveloper’sperspective
Module2DefiningData
Creatingdatatemplates
Datatemplateinheritance
Standardvalues
Insertoptions
Summaryandoptionallab
Module3Presentation
Presentationisdynamicandmodular
SettingupaVisualStudioProject
CreatingalayoutCreatingcomponents
DynamicbindingRenderingcontent
Module4SitecoreAPI
BasicAPIconcepts&retrievingitems
Itemlinks
Creating,deleting,andmodifyingitems
Workingwithcomplexfields
Module5AdvancedPresentation
Concepts
Reusablecontent
Layoutdeltas
Module6RealWorldSolutions
Familiarconcepts
Dealingwithlargersites
Sitecorequery
Module7ConfiguringthePageEditor
Datasource restrictions
Parametersandparametertemplates
Placeholdersettings
AdvancedPageEditorconfiguration
Module8DealingWithYourData
Itembuckets
Search
Module9RecommendedPractices
WorkingwithmediaCaching&performance
PublishingInstalling&scaling
Teamdevelopment Dealingwithdeployment
BasicsecurityWorkflow
Module10MarketingFunctionality
Introduction
Engagementvalues&goals
Profiling&personalization
Module11OptionalTopics
Branchtemplates
Otheritemandtemplateproperties
Pipelinesandevents
Rules
Placeholderoverrides
ExamandCertification
Theoryexamwith40questions
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 11
WhatIsSitecore?
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
ListkeyfeaturesofSitecoreCustomerExperiencePlatform(XP).
Describeatypicalscenarioforavisitor.
Findtheinformationthatyouneed.
Contactsupport.
Content
SitecoreIsaCustomerExperiencePlatform
CrossChannelCommunication
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 12
ATypicalScenario
TheDeveloper’sRole
 
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 13
What'sinitforyou?
 
WhereCanIFindMoreInformation?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 14
HowDoIContactSupport?
TaskSignUpfortheSDN

Browseto
http://sdn.sitecore.net/.
Register,makingsurethatyournameiswrittenasyouwantittoappearonthecourse
certificate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 15
SitecorefromanAuthor’sPerspective
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
NamethreeinterfacesthatSitecorebusinessusershaveaccessto.
Determinewhichinterfaceissuitableforwhichtask.
ExplainhowSitecoredataisrepresentedtoauthors.
Nametheprocessbywhichcontentispushedtoaliveenvironment.
Content
SitecoreasaContentManagementSystem(CMS)andMarketingPlatform
 
DemoSitecoreInterfaces
1. Openthetrainingsiteinabrowserandappend/sitecoretotheURL(forexample,
http://BasicSitecore/sitecore).
2. Loginastheadministrator(password:b).
Note
Therearethreeinterfacesusedforediting:PageEditor,ContentEditorandDesktop.
3. DoubleclickthePageEditoricontologintothatinterface.
4. Expandtheribbonusingthearrowinthetoprighthandcorner.

Inthefollowingdemo,wewill:
LogintothevariousSitecoreinterfaces.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 16
5. Exploresomeofthetabs:
Homeforcommonadd/delete/movetasks
Experienceforchanginglanguages
6. ClicktheViewtab.NoticethatboththeEnableandShowcheckboxesarenotselected.
7. SelecttheNavigationbarcheckbox.
Note
Thenavigationbarisappendedtotheribbon.Thisallowsauthorstonavigatethroughthesitestructure
byselectingtheappropriateitemandclickingGo.
8. Navigatetothe/home/whichbikeitem.
DemoEditinginPageEditor
1. OntheViewtab,selecttheEditingcheckboxandhoveroverthevariousareasofthepagesuchasan
image,sometextandsoon.TheEditFrametoolbarappears.Theeditingoptionsavailableonthe
toolbardependuponthetypeofcontent(imageortext)thatyouhaveselected.
2. ClicktheWhichbike?titleandchangeittoWhichbikeshouldIchoose?
3. Clickthetopleftcornertosavetheeditedtitle.
4. OntheHometab,clickInsertandselectanewStandardContenttemplate.
5. GivethetemplatethenameBikesforbeginners.Youhavenowcreatedanewpage.
Note
Thebreadcrumbsautomaticallyknowwhattodisplay.
6. NavigatebacktotheWhichbike?Item.Thepagethatyoujustinsertedhasbeenautomaticallyaddedto
thelisting.

Inthefollowingdemo,wewill:
UsethePageEditortoeditcontentinline.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 17
DemoDesigninginPageEditor
1. ClicktheViewtab.
2. CleartheEditingcheckboxandselecttheDesigningcheckboxinstead.
3. ClickvariouscomponentsontheWhichBikepage.
Note
Youcannolongereditcontent,butyoucannowselectareasoffunctionalityonthepage.Youstillgetan
editframe,buttheoptionsarecommandslikeMoveorDelete.
4. OntheHometab,clickAddComponent(orthecorrespondingiconnexttothetab).AnumberofAdd
toherebuttonsappearwhereyoucaninsertacomponent.
5. ClickthebuttonatthetopofthelefthandcolumnandselecttheSubnavigationcomponentandthen
clickSelect.
6. Ifthelistonthispageislong,youmightwanttopresentaquickoverviewbyaddingasidenavigation
component.Todothat,clickAddtohereatthetopofthelefthandcolumnandchooseaSide
Navigationcomponent.
7. Verifythatacomponentthatlistsallthepagetitles,includingtheonethatyoujustcreated,appearson
thepage.
DemoDesktopandContentEditor
1. ClicktheLogoffbuttonandgobacktothe/sitecoreinterfacesmenu.
2. ClickOptions.
3. LoginastheadministratoranddoubleclicktheDesktopicon.
4. ClicktheSitecorebuttonandopentheContentEditor.
Note
ThereareavarietyofinterfacesthatcanbeaccessedviatheDesktopicon.
5. TypeWhichbikeinthesearchbarabovetheSitecoretree.Theitemthatwaseditedearlierisdisplayedin
theresultset.
6. Opentheitem.Itismadeupofseveraldifferenttypesoffields.
Note
TheHeadingfieldnowreadsWhichbikeshouldIchoose?becauseitwaschangedusingthePageEditor
interface.
7. ChangetheHeadingfieldtoChoicesofbikeandthen,ontheribbon,clickPublish>Previewtoseethe
changes.
In
thefollowingdemo,wewill:
UsethePageEditortodesignapage.
Inthefollowingdemo,wewill:
UseContentEditortoeditandpublishcontent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 18
8. Ifyouarehappywiththechanges,clickthearrownexttoPublish>Publishsite,andselectthe
IncrementalPublish
optiontopublishthechangeditems.
9. LogoffandviewtheWhichbike?pageasaregularvisitor.Becausewehavepublishedthechanges,the
itemshavebeenpushedfromthesandboxenvironmenttothewebenvironment.
YoucanaccesstheLoginscreenbynavigatingtotheHomepagewith/sitecoreappendedtothesite’sURL.Click
theOptionsbuttontochooseoneofthreeeditorenvironments:
ThePageEditordisplaysindividualpageswithaneditingribbonthatallowsbusinessusersto
eithereditcontentinline(changingtextoraddingmedialikeimages)ormodifythepagelayout
(addingorremovingareasonthepage).
TheContentEditorallowsabusinessusertoworkdirectlywiththeallthedatastoredin
Sitecore.UnlikeinthePageEditor,authorsinthiseditorenvironmentareeditingtheactual
dataexcludinganypresentation.
TheSitecoreDesktopusesthefamiliar“Windows”metaphorwithaStartbuttonandmenuto
accessallSitecoreinterfaces,includingthePageEditorandContentEditor.Theactualtools
authorsseedependontheirsecuritycontext;administratorsseeeverything.
ItemsandtheContentTree

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 19
PublishingandtheSitecoreDatabases
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 20
SitecorefromaDeveloper’sPerspective
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
ExplainwhatgetsinstalledonyourcomputerwhenyouinstallSitecore.
NamethreeSitecoredatabases.
NamefourfoundationfeaturesthatSitecoreprovidesoutofthebox.
Drawouttheminimumrequirementsforaproductionenvironment.
Content
ArchitectureandRequirements
SeparationofConcerns
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 21
HowSitecoreHandlesaRequest
WhatGetsInstalled?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 22
InstallationScenarios‐RecommendedMinimum
ARealisticExample

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 23
DefiningData
Contents
CreatingDataTemplates
DataTemplateInheritance
StandardValues
InsertOptions
SummaryandOptionalLab

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 24
CreatingDataTemplates
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
CreateadatatemplateusingSitecoreRocks.
Content
Items,Fields,andDataTemplates
FieldTypeDetermines…

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 25
FieldSource
WhoDecidesWhattheDataStructureWillBe?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 26
AreFieldsShared?
WeUseSitecoreRocks
Tip
FormoreinformationaboutSitecoreRocks,see:
http://www.sitecore.net/Learn/Blogs/TechnicalBlogs/TrevorCampbell/Posts/2013/02/28Daysof
SitecoreRocksIntro.aspx
DemoCreatingaDataTemplate
Inthisdemo,wewill:
CreateanewdatatemplatenamedBase.
Addthreefieldstothetemplate:Heading,MainImage,andMainContent.
Note:Youwillperformthesetasksintheupcominglabs.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 27
ApplyTopic2.1
CreatingaBaseDataTemplate
CreateaDataTemplateNamedBase
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpenVisualStudio.
2. ToopenSitecoreExplorer,selectSitecore>SitecoreExplorerintheVisualStudiotoolbar.
3. LocateyourinstanceintheSitecoreExplorerwindowunderConnections><LocalIISSites>.The
instancenameisBasicSitecoreunlessyourinstructortellsyouotherwise.

YoucanfindablankinstallationofSitecoreonyourstudentcomputer.Yourinstructorwillgiveyouthe
URL.Throughoutthismanual,thehostnamefortheblankSitecoreinstancewillbereferredtoas
http://basicsitecore/.Ifyourhostnameisdifferent,thenpleaseadjusttheURLsaccordingly.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,connecttotheBasicSitecoreinstance,createadatatemplatecalledBaseunder
master/sitecore/Templates/UserDefined.
Createfieldsectionsandfieldsasdescribedinthefollowingtable:
Fieldsection
BasicInformation
Fieldname
Fieldtype
Heading
Singlelinetext
Main
Content
RichText
MainImage
Image
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 28
4. RightclickBasicSitecoreandselectScopetoThis.
5. ExpandintheBasicSitecorebyclickingthearrowtotheleftoftheservericon.
6. Expandthemasterdatabase.
7. ContinuetoexpanditemsuntilyoucanseetheUserDefinedfolderunder:
/BasicSitecore/master/sitecore/templates/UserDefined.
8. RightclickUserDefinedandselectNewTemplate…
KeyboardShortcut
CTRL+Shift+Space=Commandy
Commandyissimilarto“NavigateTo…”functioninVisualStudio;it’sautilityforfindingfunctionsin
SitecoreRocks.Selectanitemandusethecommandtobringupasearchablelistofavailabletasks.
9. NamethedatatemplateBase.
10. Createfieldsectionsandfieldsasdescribedinthefollowingtable:
Fieldsection
BasicInformation
Fieldname
Fieldtype
Heading
Singlelinetext
MainContent
RichText
MainImage
Image
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 29
Yourfinalscreenshouldlooklikethis:
11. ClickSave.
Extend
DataDefinitionReference
http://sdn.sitecore.net/Reference/Sitecore%207/Data%20Definition%20Reference.aspx
ContentAuthor’sCookbook
http://sdn.sitecore.net/Reference/Sitecore%207/Content%20Authors%20Cookbook.aspx

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 30
DataTemplateInheritance
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Specifythebasetemplatesadatatemplateinheritsfrom.
Describethebenefitsofdatatemplateinheritance.
Namethedatatemplatethatalldatatemplatesinheritfrom.
Content
RECAP:ChallengeswithFieldDuplication
DataTemplateInheritance

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 31
Tip
Adatatemplatecaninheritfromanynumberofbasetemplates.
Youcanuseadatatemplatemultipletimesintheinheritancechain(forexample,ifBaseandHolidayboth
inheritfromStandardValues,thefieldswillnotappeartwice).
BestPractice
Althoughyoucanuseadatatemplatemultipletimesintheinheritancechain,youshouldavoidcreating
acirculartemplateinheritance(ABA).
Similarly,fieldnamesmustbeunique.YoucannotdefineTitlefieldinbothBaseandHolidaytemplates
andexpecttobeabletotargetthemasseparatefieldsinthelatter’ssupersetoffields.Theydonot
mergeliketemplatesectionsdo.
Neverinheritafieldthatanitemisnotgoingtouse(forexample,ifanauthorcanpopulateafieldthatis
neverrenderedorused,considerrevisingyourinheritancechain).
Overusingdatatemplateinheritancecanquicklybecomedifficulttomanagebeyond3or4levels.
ResultingDataTemplates
Important
Datatemplateinheritanceshouldbeconsideredatthestartofyourproject.Movingfieldsintoabase
templateafteritemshavebeencreatedusingthatdatatemplatewillresultinalossofdata.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 32
DemoSettingUpandViewingDataTemplateInheritance
BestPractice
Encapsulateallfieldsrequiredforaspecificfeatureinadatatemplate,whichothertemplatescanthen
inheritfrom.Forexample:
PageMetaData[Title,Description,Keywords]
or
Banner[BannerImage,BannerText]
Tip
ByenablingstandardfieldsintheViewgroupintheContentEditor,youcanseealltheadditionalfields
derivedfromtheStandardTemplate.RightclickintheEditorPaneinSitecoreRockstoseethe
standardfieldsaswell.
CreatingItems
Inthisdemowewillbe:
CreatingaHolidaysSectiondatatemplate.
ChoosinganiconfortheHolidaysSectiondatatemplate.
ConfiguringtheHolidaysSectiondatatemplatetoinheritfromBase.
CreatingaFamilyHolidaysitembasedontheHolidaysSectiondatatemplate.
CreateaTripDetailsdatatemplateandconfigureittoinheritfromBase
CreatingaCycletheCotswoldsitembasedontheTripDetaildatatemplateunderthe
FamilyHolidaysitem.
ViewingthelistofdatatemplatesthattheCycletheCotswoldsiteminherits.
Note:Youwillperformthistaskintheupcominglab.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 33
ApplyTopic2.2
DataTemplateInheritance
CreateOneDataTemplateNamedHolidaysSectionandAnotherNamedTripDetail
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSitecoreExplorertoolbar.
2. ExpandtheBasicSitecoresolutionuntilyoucansee:/BasicSitecore/master/sitecore/Templates/User
Defined.
3. RightclicktheUserDefinedfolderandselectNewTemplate…tocreateanewtemplate.
4. NamethetemplateHolidaysSection.
5. DoubleclicktheHolidaysSectiontemplatetoopenit.Clicktheiconinthetoplefthandcornertoopen
theiconselectiondialog.
6. ClicktheSearchtabandsearchfor“star”.
Inthefollowinglabs,youwilluseSitecoreRocksto:
CreateHolidaysSectionandTrip
Detailsdatatemplates.
Configurebothdatatemplatesto
inheritfromBase.
CreateasitetreeusingtheHolidays
SectionandTripDetaildata
templates.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,createadatatemplatenamedHolidaysSectionunder:/sitecore/Templates/User
Definedandassignastaricontoit.Thisdatatemplatedoesnotrequireanyadditionalfields.
CreateaseconddatatemplatenamedTripDetailsunder/sitecore/Templates/UserDefinedandassigna
globeicontoit.Createfieldsectionsandfieldasdescribedinthefollowingtable:
Fieldsection
TripInformation
Fieldname
Fieldtype
Priceper
person
Singlelinetext
Startdate
Date
Attheendofthislab,youshouldhavethreedatatemplatesundertheUserDefinedfolder:

Base
Holidays
Section Trip
Detail
Bicycle
Detail
Figure21Datatemplateinheritancestructure
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 34
7. SelecttheyellowstariconandclickOK.
8. Save.Yourdatatemplatewilllooklikethis:
9. RightclicktheUserDefinedfolderandselectNewTemplate…tocreateanewtemplate.
10. NamethetemplateTripDetails.
11. ChangetheTripDetailsdatatemplate’sicontoanearthicon.
12. Createfieldsectionsandfieldsasdescribedbythefollowingtable:
Fieldsection
TripInformation
Fieldname
Fieldtype
Priceperperson
Singlelinetext
Startdate
Date
13. Save.Yourdatatemplatewilllooklikethis:

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 35
ConfigureHolidaysSectionandTripDetailstoInheritfromBase
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. EnsurethatyouareintheSitecoreExplorertoolbarinVisualStudio.LocatetheHolidaysSectiondata
templateunder:/BasicSitecore/master/Templates/UserDefined/HolidaysSection.
2. DoubleclicktheHolidaysSectionitemtoopenit.
3. RightclickinsidethegreyspaceandselectSetBaseTemplates:
4. TypebaseintheSearchfieldandselecttheBasecheckbox:
5. ClickOKandSave.
6. RepeatthesameprocessfortheTripDetailsdatatemplate.Thisdatatemplateshouldalsoinheritfrom
Base.

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,opentheHolidaysSectiondatatemplateandrightclickinsidethegreyspace.
SelectSetBaseTemplatesandselectBase.RepeattheprocessforTripDetails.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 36
CreateContentItemsUsingtheHolidayListingandTripDetailsDataTemplates
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,rightclickontheHomeitemunder:/BasicSitecore/master/sitecore/Contentand
createanewitembasedontheHolidaysSectionitem.NameitFamilyHolidays.Populateitwiththe
followingsamplecontent,orwriteyourown:
FamilyHolidays
BasicInformation
Heading
HolidaysfortheEntireFamily
MainContent
Takethekidsonacyclingadventurethissummer!
Main
Image
A
nyfromthemedialibrary
AsachildoftheFamilyHolidaysitem,createanewitembasedontheTripDetailsdatatemplate.Name
thisitemExploreHolland.Usethefollowingsamplecontentorwriteyourown:
ExploreHolland
BasicInformation
Heading
ExploreHolland
MainContent
Explore
Holland
Main
Image
A
nyfromthemedialibrary
TripInformation
Priceperperson
$600(oruseanyvalue)
Startdate
4/24/2013(orenteranydate)
Youwillendupwithacontenttreethatlookslikethis:

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 37
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSitecoreExplorer.
2. LocatetheHomeitemunder/BasicSitecore/master/sitecore/Content/Home.
3. RightclickontheHomeitemandselectAdd>NewItem
4. SearchforHolidaysSectionintheAddNewItemdialog.MakesurethatAllisselectedinthelisttothe
left:
5. NametheitemFamilyHolidaysandclickOK.
6. Populatetheitemwiththefollowingsamplecontent,orwriteyourown:
Family
Holidays
BasicInformation
Heading
HolidaysfortheEntireFamily
MainContent
Takethekidsonacyclingadventurethissummer!
Main
Image
A
nyfromthemedialibrary

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 38
7. Toinsertanimage,draganddropanimagefilefromthefilesystemortheSitecoreMediaLibraryonto
theimageplaceholdericonundertheMainImagefield.Therearesampleimagesavailableinthe
StudentResourcesFolderonthefilesystemunder:StudentResourcesFolder>WNDLabs>Images.
8. RightclicktheFamilyHolidaysitemandinsertanewchilditembasedontheTripDetailsdata
template.NamethisitemExploreHolland.
9. Populatetheitemwiththefollowingcontent,orwriteyourown:
ExploreHolland
BasicInformation
Heading
ExploreHolland
Main
Content
ExploreHolland
Main
Image
A
nyfromthemedialibrary
HolidayInformation
Priceperperson
$600(oruseanyvalue)
Startdate
4/24/2013(orenteranydate)
Tip
Toviewalistofdatatemplatesthatanitemordatatemplateinheritsfrom,rightclicktheitemand
selectNavigate>TemplateHierarchy.Twoiconsallowyoutoseeinheritedandinheritingdata
templates.ThefollowingimageshowswhichdatatemplatestheFamilyHolidaysitemisinheritedfrom:

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 39
StandardValues
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Createanitem’sstandardvaluesusingSitecoreRocks.
Usestandardvaluestosetthedefaultcontentofadatatemplate.
Usertokenstoinsertdynamicfieldvalues.
Resetanitem’sfieldvaluesbacktothestandardvaluesofitsdatatemplate.
Listthepropertiesofanitemthataresetonitsstandardvaluesasrecommendedpractice.
Content
StandardValuesAllowYoutoSetUpDefaults
StandardValuesandInheritance
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 40
Tokens
TokenName
Description
$name
Nameoftheitem
$time
IDoftheitem
$no
w
IDoftheparentoftheitem
$date
Nameoftheparentoftheitem
$time
Currentdate(ISOformat)
$no
w
Current
time(ISOformat)
$date
Currentdateandtime(ISOformat)
Important
Thesetokensareonlyexpandedwhenyouarecreatinganitem.Thismeansthatifyouadda$name
tokentoafieldintemplate’sstandardvalues,itemsthathavealreadybeencreatedwillliterallyhave
$nameinthatfield.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 41
ItemNamingConventions
NoteURLDuplication
Sitecorewillwarnyouaboutduplicateitemnamesonthesamelevel,butitwillnotstopyou
fromcreatingthem.Thesolutionsaretoeithercreateapipelinetorenametheitematitem
creationtime,orcreateavalidationruletointerceptanddenysavingtheitem.
DemoStandardValues,Tokens,andDefaultFieldValues
Tip
Toresetanitem’sfieldtothevalueinstandardvalues,rightclickthefieldnameandselectResetto
StandardValueonSave,thensavechanges.

Inthisdemo,wewill:
CreatestandardvaluesfortheBasedatatemplate.
Adda$nametokentotheHeadingfield.
AddLoremipsumcontenttotheMainContentfield.
CreateanewitembasedontheTripDetailsdatatemplate.
ChangeMainContentandresettostandardvalues.
Youwillbeperformingthesetasksintheupcominglab.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 42
ApplyTopic2.3
CreateandUseStandardValues
CreateStandardValuesandPopulatewithTokensandSampleContent
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSitecoreExplorer.
2. LocatetheBasedatatemplateunder:/BasicSitecore/master/sitecore/Templates/UserDefinedBase.
3. Doubleclickthedatatemplatetoopenit.
4. RightclickinsidethegreyspaceintherighthandpanelandselectCreateStandardValues.Thiswill
createa__StandardValuesitemasachildofBase.RightclickBaseandclickRefreshtoseeit.
5. Ensurethatthenewlycreated__StandardValuesitemisselected.
6. Type$nameintotheHeadingfield.
7. RightclicktheMainContentfieldandselectAdd‘LoremIpsum…’,ortypeyourownsamplecontent.
8. ClickSave.

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,createtheStandardValuesfortheBasedatatemplate.
Adda$nametokentotheHeadingfield,andsamplecontent,LoremIpsumtotheMainContentfield.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 43
CreateaNewTripDetailsItem
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSitecoreExplorer.
2. LocatetheFamilyHolidaysitemunder:/BasicSitecore/master/sitecore/Content/Home/FamilyHolidays.
3. RightclicktheFamilyHolidaysitemandselectAdd>NewItem…
4. InsertanewitembasedontheTripDetailsdatatemplate.NamethisitemDiscovertheCotswolds.
Becausewehavesetupdefaultvaluesandtokens,youritemwillbeprepopulatedwithcontent:
5. Populatetheremainingfieldswithsamplecontentfromthefollowingtable,orwriteyourown:
DiscovertheCotswolds
BasicInformation
MainImage
A
nyfromthemedialibrary
TripInformation
Priceperperson
$800(oruseanyvalue)
Startdate
5/1/2013(orenteranydate)
6. ClickSave.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,createanewTripDetailsitemunder:/Home/FamilyHolidays.NameitDiscover
theCotswolds.
NotethattheHeadingfieldisreplacedbytheitem’sname,andtheMainContentfieldcontains
samplecontent,“Loremipsum…”.Populatetheremainingfieldswithsamplecontentforthefollowing
table,orwriteyourown.
DiscovertheCotswolds
BasicInformation
MainImage
A
nyfromthemedialibrary
TripInformation
Priceperperson
$800(oruseanyvalue)
Startdate
5/1/2013(orenteranydate)
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 44
InsertOptions
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Assigninsertoptionstoadatatemplate.
Explainwhyrecommendedpracticeistoassigninsertoptionstostandardvalues.
Explainwhyauthorsrequireinsertoptions.
Content
WhatAreInsertOptions?
DemoAssignInsertOptions
In
thisdemo,wewill:
AssigninsertoptionstotheHolidaysSectiondatatemplate.
CreateanewTripDetailsitemundertheFamilyHolidaysitem.
Note:Youwillbeperformingthesetasksintheupcominglab.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 45
ApplyTopic2.4
AssignInsertOptions
AddTripDetailsasanInsertOptionontheHolidaysSectionDataTemplate
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSitecoreExplorer.
2. LocatetheHolidaysSectiondatatemplateunder:/BasicSitecore/master/sitecore/Templates/User
Defined/HolidaysSection.
3. Doubleclickthedatatemplatetoopenit.
4. RightclickinthegreyspaceinsidethelefthandpanelandselectCreateStandardValues.
5. RightclicktheHolidaysSectioniteminthetreeandclickRefresh.Thestandardvaluesitemwillappear
asachildofthedatatemplate:
6. Rightclickthe__StandardValuesitem.SelectTasks>SetInsertOptions.
7. SearchforTripDetailsandselecttheTripDetailscheckbox:
8. ClickOKandSave.
9. TotestthatTripDetailsnowappearasaninsertoptionontheHolidaySectiondatatemplate,right
clickontheFamilyHolidaysitemandensurethatTripDetailsappears.

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,addTripDetailsasaninsertoptiontotheHolidaysSectiondatatemplate.
Remembertoassigninsertoptionsonthedatatemplate’sstandardvalues.Testthatthedatatemplate
nowappearsasaninsertoption
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 46
SummaryandOptionalLab
Introduction
Objectives
Thistopiccovers:
Asummaryofkeyvocabulary
Asummaryofstandardvaluesversusdatatemplates
Asummaryofkeysteps
Anoptionallab
Content
KeyVocabulary
DataTemplateVersusStandardValues
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 47
DataDefinitionSteps
ApplyTopic2.5Optional
CreateaBicycleDetailsDataTemplate

OverviewSteps
Thisisasummarylabbasedoneverythingyouhavelearnedinthismodule.Refertopreviouslabsfordetailed
instructions.
UsingSitecoreRocks,createaBicycleDetailsdatatemplateusingthefollowinginformation:
ThedatatemplatemustinheritfromBase.
Thedatatemplatemustcontainthefollowingfields:
BicycleDetails
BicycleInformation
Fieldname
Fieldtype
Suitability
Singlelinetext
Type
Singlelinetext
ItmustbepossibleforauthorstocreateBicycleDetailsitemsunderTripDetailsitems.
TheSuitabilityfieldshouldcontain“All”bydefault.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 48
Presentation
Contents
PresentationIsDynamicandModular
PreparingtoBuild
CreatingaLayout
CreatingComponents
DynamicBinding
RenderingContent
SummaryandOptionalLab
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 49
PresentationIsDynamicandModular
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
ExplainhowSitecoreresolvesapagecomparedtoastaticsite.
Definepresentationdetailsingeneralterms.
Content
HowSitecoreResolvesaPage
ADetailedLookataRequest
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 50
PresentationDetails
DemoModifyaPresentationwithPageEditor
Tip
Toviewanitem’spresentationdetailsinSitecoreRocks,selecttheitemandpressCTRL+U:
Inthisdemowewill:
CreateanewStandardContentiteminTraincore.
UseSitecoreRockstoviewthepresentation.
AddaBannerandGeneralWidgetcomponenttothenewlycreatedpage.
UseSitecoreRockstoviewchangesinpresentation.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 51
PreparingtoBuild
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Breakadesignintocomponents.
SetupaVisualStudioprojecttoworkwithSitecore.
Content
BreakYourDesignintoComponents
Tip
Formoreinformationonhowtocomponentizeapage,seethePageEditorRecommendedPractices
GuidefordevelopersontheSDN:
http://sdn.sitecore.net/reference/sitecore%207/page%20editor%20recommended%20practices%20for
%20developers.aspx
HowWouldYouComponentizeYourownSites?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 52
CreateaVisualStudioProject
DemoCreatingaProject
Important
Inthedevelopmentenvironment,werecommendthatyouworkoutsidethewebrootanddeployyour
filesonafreshSitecoreinstance.Todothis,usePublishProfilesoraproductlikeHedgehog’sTeam
DevelopmentforSitecore.
Inthisdemowewill:
CreateanewASP.NETEmptyWebApplication(C#)projectinVisualStudio2012called
BasicSitecoretocorrespondtoourSitecoreinstance.
Movethe.slnand.csprojfilesintothewebroot.
Includetheweb.configandLayoutsfolder.
ConnecttheprojecttoSitecoreRocks
AddareferencetotheSitecore.Kernell.dll.
Youwillperformthesetasksintheupcomingdemo.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 53
ApplyTopic3.2
CreateaVisualStudioProjectandConnectIttoSitecoreRocks
LabA. CreateanASP.NETEmptyWebApplicationProjectintheWebRoot
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpenVisualStudio.
2. OntheVisualStudiotoolbar,selectFile>New>Project
3. SelectASP.NETEmptyWebApplication(C#)fromVisualC#>Websection:
4. NametheprojectBasicSitecore,andchangetheLocationtothewebrootofyourSitecoreinstance.
Thisdiffersdependingonthecomputeryouareusing,butislikelytobe:
C:\inetpub\wwwroot\BasicSitecore\Website.
ThewebrootspecificallyreferstotheWebsitefolder,wheretheweb.configlives.
Inthefollowinglabs,youwillsetupa
VisualStudio
project
toworkwithSitecore.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
InVisualStudio,createanASP.NETEmptyWebApplicationintheSitecorewebsite’swebroot.Nameit
BasicSitecore.YoudonotneedtocreateanentirelynewfolderforBasicSitecore.
Inthefilesystem,movethefollowingfilesandfoldersoutofthenewlycreatedprojectfolderandintothe
Websiteroot:
.sln
.csproj
Propertiesfolder
objfolder
Deletewhatremainsintheprojectfolder.Openthe.slnfileinitsnewlocationandmovethelayoutsfolder
intotheproject.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 54
5. CleartheCreatedirectoryforsolutioncheckbox.Yourscreenshouldlooksomethinglikethis:
6. ClickOK.
7. Thesolutionwillappearinasubfolderinthewebroot.Someofthecontentsofthissubfolderneedtobe
movedintothewebroot.ClosethesolutionnavigatingtoFile>CloseSolutionontheVisualStudio
toolbar.
8. Inthefilesystem,navigatetoyourSitecorewebsite’swebroot.Forexample:
C:\Inetpub\wwwroot\BasicSitecore\Website
9. LocatetheBasicSitecorefolderthatyoujustcreated:
10. Openthisfolder.Copythefollowingfilesandfoldersintothewebroot(onefolderabove).Yourfiles
shouldenduponthesamelevelasSitecore’sownweb.config:
BasicSitecore.sln
BasicSitecore.csproj
Properties
obj
DonotoverwriteSitecore’sownweb.config.Yourprojectfoldersandfilesarenowmixedinwiththe
defaultSitecorefoldersandfilesinthewebroot:
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 55
11. YoucannowdeletetheremainingBasicSitecorefolderfromthewebroot.
12. GobacktoVisualStudioandopenthe.slnfilefromitsnewlocationinsidethewebroot
13. Doubleclicktheweb.configfile.ConfirmthatitisSitecore’sweb.configfile,whichismuchlargerthan
yourproject’sweb.configfile(youcanalsosearchforsitecore).
14. InSolutionExplorer,selecttheBasicSitecoreprojectandclickShowAllFiles:
15. RightclickonthelayoutsfolderandselectIncludeinproject.ClickShowAllFilesagaintohideallother
hiddenfiles.Yourfinalprojectshouldlooklikethis:
LabB. ConnectYourProjecttoSitecoreRocks
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,rightclicktheBasicSitecoreproject.
2. SelectSitecore>ConnecttoSitecore...
3. LocatetheBasicSitecoreinstanceinthelist,selectit,andclickOK:
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
RightclicktheBasicSitecoreprojectandselectSitecore>ConnecttoSitecore…
LocateyourinstanceinthelistandclickOKtoconnectittoyourproject.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 56
LabC. AddaReferencetotheSitecore.Kernel.dll
Detailedsteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. Inthewebroot,createalibrariesfolder.
2. InVisualStudio,expandtheBasicSitecoreproject.
3. RightclickReferencesandselectAddReference…
4. ClickBrowseinthebottomrighthandcorner:
5. BrowsetoBasicSitecorewebrootandopenthebinfolder.Yourpathmaybe:
c:\inetpub\wwwroot\BasicSitecore\Website\bin
6. Putacopyofbin\Sitecore.Kernel.dllinthelibrariesfolder.
7. Selectlibraries\Sitecore.Kernel.dllandclickAdd.ConfirmthattheSitecore.Kernelappearsinthe
Referenceslist:

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
Addareferencetolibraries\Sitecore.Kernel.dlltotheproject.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 57
CreatingaLayout
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
CreatealayoutusingSitecoreRocks.
Assignalayouttoadatatemplate’sstandardvalues.
Content
OneLayoutforAllItemsWithinaSite
WhatIsaLayout?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 58
AssigningaLayout
CreatingandAssigningaLayout
ApplyTopic3.3
CreatingandAssigningaLayout
CreateaLayoutCalledMain
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpentheVisualStudioSolutionExplorer(nottheSitecoreExplorer)
Inthisdemowewill:
CreatealayoutusingSitecoreRocksthiscreatesboththefileandtheitem.
PastesampleHTMLintothelayout.aspxfile.
AssignlayouttoBasedatatemplate’sstandardvalues.
PreviewanitemthatinheritsfromBase.
InthefollowinglabsyouwilluseSitecoreRocksto:
CreatealayoutcalledMainandpopulatethe.aspxfilewithsomesampleHTML.
AssignthelayouttotheBasedatatemplate’sstandardvalues.
Previewanexistingitem.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingVisualStudio’sSolutionExplorer,createanewSitecorelayoutinthelayoutsfolder.Whenyouare
promptedbySitecoreRockstochoosealocationforthecorrespondingitem,navigateto:
/BasicSitecore/master/sitecore/Layout/Layouts.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 59
2. RightclicktheLayoutsfolderandselectAdd>Newitem…
3. IntheAddNewItemdialog,locatetheSitecoretemplatesinthelefthandcolumn.Expandthetree
untilyouseeLayouts,andselectit.
4. SelectLayoutintherighthandpanel,andcallitMain.aspx:
5. ClickAdd,andwaitforSitecoreRockstopromptyoutocreateanitem.
6. WhenpromptedbySitecoreRockstocreatealayoutitem,navigateto:
/BasicSitecore/master/sitecore/Layoutsandselectit.
7. ClickOK.
8. UsingSitecoreExplorer,rightclickandrefreshthe/BasicSitecore/master/sitecore/Layoutsitem.
9. ConfirmthatthattheMainlayoutitemappears:

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 60
PasteSampleHTMLintotheMain.aspxFile
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpentheVisualStudio’sSolutionExplorer(nottheSitecoreExplorer).
2. OpenMain.aspx,locatedinthelayoutsfolder.
3. DeletethesampleHTML,takingcarenottodeletethetopthreelines:
CodeSample
<%@Pagelanguage="c#"Codepage="65001"AutoEventWireup="true"
Inherits="BasicSitecore.layouts.Main"CodeBehind="Main.aspx.cs"%>
<%@RegisterTagPrefix="sc"Namespace="Sitecore.Web.UI.WebControls"Assembly="Sitecore.Kernel"
%>
<%@OutputCacheLocation="None"VaryByParam="none"%>
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingVisualStudio’sSolutionExplorer,pastethefollowingsampleHTMLintoyourMain.aspxfile.Ensure
thatyoudonotaccidentallydeletethepagedirectiveatthetop.
DraganddropthecssandimgfoldersfromStudentResourcesFolder>WNDLabs>Module3>Topic
3.3>campaignpage.htmlintoyourVisualStudiosolution.
<!DOCTYPEhtml>
<!‐‐[if(gteIE9)|!(IE)]><!‐‐><html><!‐‐<![endif]‐‐>
<head>
<metacharset="utf8"/>
<title>CampaignPage</title>
<metaname="description"content="Test"/>
<metaname="author"content=""/>
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<linkrel="stylesheet"href="/css/campaigns.css"/>
</head>
<body>
<formid="Form1"runat="server"method="post">
<divclass="container">
<divclass="indentedSectioncontent">
<!‐‐HEADING‐‐>
<h1>Cyclingholidays</h1>
<!‐‐MAINIMAGE‐‐>
<imgsrc="/img/mainimage.png"class="right"/>
<!‐‐MAINCONTENT‐‐>
<ul>
<li><ahref="campaignpageholidaydetail.html">CycleLondon</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverHelsinkiin5Days</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverCopenhagen</a></li>
</ul>
<p>WouldyouliketowinaholidaytotheWelshmountainsforyouandyourfamily?3daysof<a
href="#">mountainbikingandadventures</a>.</p>
</div>
</div>
</form>
</body>
</html>
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 61
4. PastethefollowingsampleHTMLfromtheStudentResourcesFolder>WNDLabs>Module3>Topic
3.3>Lab3.3BCodeSample.htmlfilefromtheStudentResourcesfolder_v7.2.0.1,intothefilebelow
thetopthreelines:
CodeSample
<!DOCTYPEhtml>
<!‐‐[if(gteIE9)|!(IE)]><!‐‐><html><!‐‐<![endif]‐‐>
<head>
<metacharset="utf8"/>
<title>CampaignPage</title>
<metaname="description"content="Test"/>
<metaname="author"content=""/>
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<linkrel="stylesheet"href="/css/campaigns.css"/>
</head>
<body>
<formid="Form1"runat="server"method="post">
<divclass="container">
<divclass="indentedSectioncontent">
<!‐‐HEADING‐‐>
<h1>Cyclingholidays</h1>
<!‐‐MAINIMAGE‐‐>
<imgsrc="img/mainimage.png"class="right"/>
<!‐‐MAINCONTENT‐‐>
<ul>
<li><ahref="campaignpageholidaydetail.html">CycleLondon</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverHelsinkiin5Days</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverCopenhagen</a></li>
</ul>
<p>WouldyouliketowinaholidaytotheWelshmountainsforyouandyourfamily?3daysof<a
href="#">mountainbikingandadventures</a>.</p>
</div>
</div>
</form>
</body>
</html>
5. Savethefile.
6. Onthefilesystem,browsetoStudentResourcesFolder>WNDLabs>Module3>Topic3.3.
7. DraganddroptheimgandcssfoldersintotheVisualStudio’sSolutionExplorer.Thefoldersshould
enduponthesamelevelasthelayoutsfolder:
8. Buildthesolution.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 62
AssignLayouttoBaseStandardValuesandPreviewFamilyHolidaysItem
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpentheSitecoreExplorerinVisualStudio.
2. Navigateto:/BasicSitecore/master/sitecore/templates/UserDefined/HolidaySection/__StandardValues
RightclickonthestandardvaluesitemandselectTasks>DesignLayout.
3. IntheLayoutdropdown,choosetheMainlayout:
4. Navigateto:/BasicSitecore/master/sitecore/Content/Home/FamilyHolidays
5. RightclicktheitemandselectTools>Browse>Preview.
6. ConfirmthattheFamilyHolidaysitemlookslikethis:

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreExplorer,assigntheMainlayouttotheHolidaySectionstandardvalues,previewthe
FamilyHolidaysitem.ConfirmthatyoursampleHTMLisnowbeingdisplayed,includingimagesandCSS.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 63
CreatingComponents
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
CreateasublayoutusingSitecoreRocks.
NamethreetypesofSitecorecomponents.
Content
Movable,ReusableComponents
WhatIsaComponent?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 64
TipSitecoreMVCVideos
Part1:https://www.youtube.com/watch?v=i3Mwcphtz4w
Part2:https://www.youtube.com/watch?v=dW_rQp9bMmE
WhatIsaSitecoreSublayout?
DemoCreatingaSublayout
ApplyTopic3.4
CreateaSublayout
LabA. CreateaSublayoutCalledIntroduction
Inthisdemowewill:
CreateasublayoutcalledIntroduction.
Movetheheading,content,andimagefromMain.aspxintotheIntroductionsublayout.
Youwillperformthesetasksintheupcominglab.
Inthefollowinglabyouwillcreateanewsublayoutcalled
Introduction
andmovetheheading,text,and
imagefromthesampleHTMLinMain.aspxintotheIntroduction.ascx.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
UsingSitecoreRocks,createanewsublayoutcalledIntroduction.Ensurethatthecorrespondingdefinition
itemiscreatedunder:/BasicSitecore/master/sitecore/Layout/Sublayouts.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 65
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio,opentheSolutionExplorer(notSitecoreExplorer).
2. RightclickthelayoutsfolderandselectAdd>NewItem
3. IntheAddNewItemdialog,navigatetoSitecore>Renderingsinthelefthandmenu.
4. SelectSublayoutintherighthandpanelandnameitIntroduction:
5. ClickAdd,andwaitforSitecoreRockstopromptyoutoaddacorrespondingitem.
6. IntheNewItemdialog,expandtheBasicSitecoretreeuntilyoucanseetheSublayoutsitemunder:
/BasicSitecore/master/sitecore/Layout/Sublayouts:
7. ClickOK.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 66
LabB. MovetheHeading,Text,andImageSampleHTMLfromMain.aspxintoIntroduction.ascx
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1.InVisualStudio’sSolutionExplorer,doubleclickMain.aspxtoopenit.
2.LocatethefollowingHTML:
CodeSample
<divclass="indentedSectioncontent">
<!‐‐HEADING‐‐>
<h1>Cyclingholidays</h1>
<!‐‐MAINIMAGE‐‐>
<imgsrc="/img/mainimage.png"class="right"/>
<!‐‐MAINCONTENT‐‐>
<ul>
<li><ahref="campaignpageholidaydetail.html">CycleLondon</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverHelsinkiin5Days</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverCopenhagen</a></li>
</ul>
<p>WouldyouliketowinaholidaytotheWelshmountainsforyouandyourfamily?3daysof<a
href="#">mountainbikingandadventures</a>.</p>
</div>
3.CutthisHTMLfromMain.aspx(orcopyitfromthecodesampleabove)andpasteitinto
Introduction.ascx.Takecarenottodeletethetoptwolinesofthe.ascxfile.
4.EnsurethatMain.aspxnolongercontainsthesampleHTMLabove.
5.Buildthesolution.
6.UsingSitecoreExplorer,rightclick:/BasicSitecore/sitecore/master/sitecore/Content/Home/FamilyHolidays
ThenselectTasks>Browse>Preview.Confirmthatthepageisblank.

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
InVisualStudio,cutthesampleHTMLfromMain.aspxthatcontainsthesampleheading,image,andtext.
InsertitintoIntroduction.ascxinstead.Forreference,theHTMLisavailablebelow.EnsurethatMain.aspx
nolongerhasthisHTML.
<divclass="indentedSectioncontent">
<!‐‐HEADING‐‐>
<h1>Cyclingholidays</h1>
<!‐‐MAINIMAGE‐‐>
<imgsrc="/img/mainimage.png"class="right"/>
<!‐‐MAINCONTENT‐‐>
<ul>
<li><ahref="campaignpageholidaydetail.html">CycleLondon</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverHelsinkiin5Days</a></li>
<li><ahref="campaignpageholidaydetail.html">DiscoverCopenhagen</a></li>
</ul>
<p>WouldyouliketowinaholidaytotheWelshmountainsforyouandyourfamily?3daysof<a
href="#">mountainbikingandadventures</a>.</p>
</div>
PreviewtheFamilyHolidaysitem.Thepageshouldbeblank.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 67
DynamicBinding
Introduction
Objectives
Bytheendofthistopic,youwillbeableto:
Assembleapageusingdynamicbinding.
Explaintheprosandconsofstaticbinding.
Content
HowDoYouBindComponentstoaLayout?
WhatArePlaceholders?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 68
BindingComponentstoPlaceholders
DemoHolidaysSectionPresentationDetails
Dynamicvs.StaticBinding
Inthisdemowewill:
CreateamaincontentplaceholderinMain.aspx.
BindIntroductioncomponenttothemaincontentplaceholderonHoidaysSection
standardvalues.
PreviewFamilyHolidays.
AddanadditionalIntroductioncomponenttoFamilyHolidaysandresetthe
presentation.
Youwillperformthesetasksintheupcominglab.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 69
ResettingthePresentation
ApplyTopic3.5
BindComponentstoPlaceholdersonStandardValues
LabA. AddaPlaceholdertoMain.aspx
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpentheVisualStudio’sSolutionExplorer(nottheSitecoreExplorer).
2. OpenMain.aspx,locatedinthelayoutsfolder.
3. Insidethe<div>tagwiththeclass“container”,insertaplaceholderwithakeyofmaincontent:
CodeSample
<divclass="container">
<sc:PlaceholderKey="maincontent"runat="server"/>
</div>
4. ClickSave.

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
InVisualStudio,openMain.aspx.Addaplaceholderwithakeyofmaincontentintothespacewhereyoucut
theheading,image,andtextHTML.Hint:insidethe<div>tagwiththeclass“container”.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 70
LabB. BindIntroductiontotheMaincontentPlaceholderonBaseStandardValues
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. UsingtheSitecoreExplorer,locatetheBasedatatemplate’sstandardvalues:
/BasicSitecore/master/sitecore/Templates/UserDefined/Base/__StandardValues.
2. Rightclickthe__StandardValuesitemandselectTasks>DesignLayout.
3. InthePresentationDetailswindow,clickAddRendering:
4. EnterIntroductionintheSearchfield.EnsurethatAllisselectedonthelefthandmenu:
5. SelecttheIntroductionrenderingandclickOK.
6. DoubleclicktheIntroductionrenderingtoopenthePropertieswindow.
7. InthePlaceholderKeyfield,typemaincontent.
8. ClickSave.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
AssigntheIntroductioncomponenttothemaincontentplaceholderontheBasedatatemplate’sstandard
values.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 71
LabC. CreateandBindtheTripOverviewComponenttoTripDetailsStandardValues
Detailedsteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. InVisualStudio’sSolutionExplorer,rightclickthelayoutsfolderandselectAdd>NewItem…
2. CreateanewSitecoresublayout.NameitTripOverview,andwaitforthepromptfromSitecoreRocks
tocreateacorrespondingitem.
3. WhenpromptedbySitecoreRockstocreateanewsublayoutitem,select:
/BasicSitecore/master/sitecore/Layout/SublayoutsandclickOK.
OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
CreateanewcomponentcalledTripOverview.UsethefollowingsampleHTML,orcopyfromStudent
ResourcesFolder>WNDLabs>Module3>Topic3.5>tripoverview.html:
<!‐‐THISISTHEHOLIDAYOVERVIEWSECTION‐‐>
<divclass="indentedSection">
<table>
<tr>
<th>Date</th>
<td>20thApril2014</td>
</tr>
<tr>
<th>Priceperperson</th>
<td>&pound;2000perperson</td>
</tr>
</table>
</div>
<!‐‐END‐‐>
BindthiscomponenttothemaincontentplaceholderontheTripDetailsdatatemplate’sstandardvalues.
Hint:Thisdatatemplateinheritsfrombase.Whenprompted,copythelayoutfromthestandardvalues
item.
BuildthesolutionandlookattheExploreHollanditeminthePageEditor.Confirmthatyouareableto
selecttheTripOverviewcomponent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 72
4. OpentheTripOverview.ascxfile.
5. CopythefollowingsampleHTMLintothe.ascxfile.Takecarenottodeletethetwolinesofcodealready
inthefile:
CodeSample
<!‐‐THISISTHETRIPOVERVIEWSECTION‐‐>
<divclass="indentedSection">
<table>
<tr>
<th>Date</th>
<td>20thApril2014</td>
</tr>
<tr>
<th>Priceperperson</th>
<td>&pound;2000perperson</td>
</tr>
</table>
</div>
<!‐‐END‐‐>
6. BuildthesolutionandclickSave.
7. UsingtheSitecoreExplorer,locatetheTripDetailsitemunder:
/BasicSitecore/master/sitecore/Templates/UserDefined/TripDetails.
8. Doubleclicktheitemtoopenit.
9. RightclickinsidethegreyareaintherighthandcontentpanelandselectCreateStandardValues.
10. Whenthenewlycreated__StandardValuesitemappears,pressCTRL+Utoopenthepresentation
details.Makesurethatyouhaveselectedthe__StandardValuesitembeforeyoudothis.
11. Whenyouarepromptedtochooseanaction,selectCopyandeditthelayoutfromtheStandardValue
item(ifany)tothisitem:
12. ClickAddRendering.
13. SearchfortheTripOverviewcomponent,selectit,andclickOK.
14. DoubleclickontheTripOverviewcomponenttoopenitsproperties.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 73
15. InthePlaceholderKeyfield,typemaincontent.
16. ClickSave.
17. InSitecoreExplorer,navigateto/BasicSitecore/master/sitecore/Content/Home/FamilyHolidaysandselect
theExploreHollanditem.
18. RightclickandselectTools>Browse>PageEditor.
19. OntheViewtabofthePageEditor,ensurethattheDesigningcheckboxisselected:
20. ConfirmthatyouareabletoselecttheTripOverviewcomponent.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 74
OutputtingContent
Introduction
Objectives
Bytheendofthistopic,youwillbeableto:
OutputcontentusinganumberofSitecorecontrols.
UseSitecorecontrolparameterstovarytheoutputofSitecorecontrols.
Content
HowDoYouOutputContent?
SitecoreControlsHaveOptionalAttributes

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 75
ApplyTopic3.6
OutputContentUsingSitecoreControls
LabA. SwapAllSampleContentforSitecoreControls
DetailedSteps
IfyoucompletedthelabusingtheOverviewStepsabove,youdonotneedtofollowthesesteps.
1. OpentheVisualStudio’sSolutionExplorer.
2. OpentheIntroduction.ascxfile.
3. Replacethesamplecontentinsidethe<h1>tagwithaSitecoreTextcontrolthatoutputstheHeading
field:
CodeSample
<h1><sc:TextField="Heading"runat="server"/></h1>
4. ReplacetheimagetagwithaSitecoreImagecontrolthatoutputstheMainImagefield.
5. Replacethesampletext(everythingunderthegreen
<!‐‐MAINCONTENT‐‐>
comment,including
paragraphs)withaSitecoreTextcontrolthatoutputstheMainContentfield.
6. ClickSave.
7. OpenTripOverview.ascx.
8. ReplacethesampledatewithaSitecoreDatecontrolthatoutputstheStartingdatefield.
ReplacethesamplepricewithaSitecoreTextcontrolthatoutputsthePriceperpersonfield.
Tip
Keepinmindthatthatfieldnamesarecasesensitive.
9. ClickSave.
10. InSitecoreExplorer,locatetheExploreHollanditem:
(/BasicSitecore/master/sitecore/Content/Home/FamilyHolidays/ExploreHolland).
11. RightclicktheExploreHollanditemandselectTools>Browse>PageEditor.
12. InthePageEditor,selecttheEditingcheckboxontheViewtab.
13. ClickintotheHeadingfieldyouarenowabletoeditthisfieldinthePageEditor:

OverviewSteps
Optionaldetailedstepsareavailablebelowtohelpyou.
InVisualStudio,openTripOverview.ascxandIntroduction.ascx.Replaceallsamplecontentwithactual
contentbyusingSitecorecontrols.Matchthecontrolusedtothetypeofcontentbeingoutput.
OpenvariouspagesinthePageEditorandconfirmthatyouareabletoeditallcontentfields.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 76
SummaryandOptionalLab
Introduction
Objectives
Thistopiccovers:
Asummaryofkeyvocabulary
TheRenderingsfield
Asummaryofkeysteps
Anoptionallab
Content
Vocabulary
TheRenderingsField
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 77
ReviewofSteps
ApplyTopic3.7Optional
SetaDefaultPresentationontheBicycleDetailDataTemplate
OverviewSteps
Thisisasummarylabbasedoneverythingyouhavelearnedinthismodule.Refertopreviouslabsfordetailed
instructions.
UsingSitecoreRocks,createaBicycleOverviewcomponentusingthefollowingsampleHTMLorcopy
fromStudentResourcesFolder>WNDLabs>Module3>Topic3.7>bicycleoverview.html:
<divclass="indentedSection">
<tableclass="bikes">
<tr>
<th>Type</th>
<td>Hybrid</td>
</tr>
<tr>
<th>Suitability</th>
<td>Familyoutings,countrylanes</td>
</tr>
</table>
</div>
SetupadefaultpresentationfortheBicycleDetailsdatatemplatethatincludestheIntroduction
componentandthenewBicycleOverviewcomponent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 78
SitecoreAPI
Contents:
BasicAPIConceptsandRetrievingItems
ItemLinks
Creating,Deleting,andModifyingItems
WorkingwithComplexFields

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 79
BasicAPIConceptsandRetrievingItems
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
DescribetheinformationtheSitecore.Contextclassprovides.
DiscusshowSitecorecodeisdebuggedina.NETsolution.
UsetheGetItem()methodtoretrieveitems.
Obtainasite’sstartitem.
Describehowtogetitemsfromanotherdatabase.
Content
Sitecore.KernelAssembly
KnowledgeCheck
WhenyouviewapageinPreviewmode,whichcontextdatabaseisaccessed?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 80
SitecoreContext
Debugging
DemoBasicAPI
1. InVisualStudio,openthecodebehindforanyexistingsublayout
(forexample,Introduction.ascx.cs).
2. EnsurethattheDebugconfigurationisselected.
3. InthePage_Loadmethod,retrieveafewpropertiesfromthe
Sitecore.Context
class(forexample,Database,Item,User,andLanguage).
4. Buildthesolution.
5. Insertabreakpoint,attachittow3wp,andnavigatetoapagethatusesthatsublayouttoexecutethe
code.
Inthisdemowewill:
Explore
Sitecore.Context
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 81
TheGetItem()Method
 
GettingItemsfromOtherDatabases
 
Important
YoumustnotquerytheSitecoredatabasesdirectly.(Thisexcludestheanalyticsdatabase.)Alwaysgo
throughtheAPI.
Tip
Itemitem1=Sitecore.Context.Database.GetItem("/sitecore/content/home");
Itemitem2=Sitecore.Context.Database.GetItem("/sitecore/content/home");
if(item1==item2)//thisisalwaysfalse;
Youarecomparingreferencestoobjects.Thevariablesabovearepointingtodifferentobjects,although
theyarethesameiteminSitecore.
SinceSitecoreitemsareuniquelyidentifiablebytheirIDs,comparisonsshouldbedoneontheitemID.
if(item1.ID==item2.ID)//dosomething;
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 82
DemoRetrievingItems
1. InVisualStudio,openthecodebehindforanyexistingsublayout(forexample,Introduction.ascx.cs)
2. RetrieveanitemfromtheSitecoretreeusingtheSitecore.Context.Database.GetItem()methodeither
bypassinginapath,oranID:
CodeSampleItemProperties
Sitecore.Context.Database.GetItem("/sitecore/content/home");
Sitecore.Context.Database.GetItem(newID("{E1B9292175C9475AA04C67401C54B39A}"));
3. LookatthefollowingpropertiesandmethodsoftheItemclass(tryusingthe/sitecore/content/Home
item):
CodeSampleItemPropertiesandMethods
Sitecore.Context.Item.Parent.Name;
Sitecore.Context.Item.GetChildren();
Sitecore.Context.Item.Children;
4. NoticethatSitecore.Context.Item.GetChildren()allowsyoutopassina
Sitecore.Collections.ChildListOptionsenum(forexample,toignoreanysecurityappliedonthoseitems).
5. Buildthesolution.
6. Addabreakpointandattachittow3wp.
7. Inabrowser,navigatetoapagethatusesthesublayoutthatyoumodified.Stepthroughtoseewhat
eachpropertyormethodreturns.
ApplyTopic4.130min
RenderItemChildren
LabA. BuildaNavigationSublayout
1. UsingVisualStudio,addanewsublayoutcalledSubnavigation(useAdd>NewItem).
2. NavigatetoSitecoreand,ontheRenderingsmenu,selecttheSublayoutoption.
Inthefollowingdemo,wewill
Use.GetItem()toretrieveanitembypathandID
ExploreItempropertiesandmethods
Use.GetChildren()and.Children
Inthefollowinglab,youwill:
Buildasubnavigationcomponenttooutputthechildrenofthecontextiteminalist.
Leavethehrefattributeblank.
Inalaterexercise,
y
ouwill
p
o
p
ulatethelink’s
hre
f
attributeswiththeitemURL.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 83
3. Youwillbepromptedtoaddanaccompanyingsublayoutdefinitionitem.Selectyourlocationinthe
Sitecoretree.

4. CopytheHTMLfromthestudentresourcefolder(WNDLabs>Module4>Topic4.1>LabA>HTML>
campaignpagenavigation.html),andpasteitintothe.ascxfile.
Donotoverwriteeverythinginthe.ascx.Keepthedirectivesandincludesatthetopofthefile.
5. Thefinishedproductwilllooklikethis:
6. UsingSitecoreRocks,navigatetotheHolidaysSectiondatatemplatestandardvaluesat
/sitecore/templates/UserDefined/HolidaysSection/__StandardValues.
7. RightclickthestandardvaluesitemandselecttheTasks>DesignLayoutoptions,oruseCommandy.
8. AddanewrenderingusingtheAddRenderingbutton.
9. AddtheSubnavigationsublayouttothemainplaceholder.Ensurethatitislistedbelowthe
Introductionsublayout.
10. SaveyourworkandpreviewtheFamilyHolidaysitem.YoushouldseetheSubnavigationsublayoutat
thebottomofthepage.(Ifyoudonotseeit,resetpresentationdetailstostandardvalue).
11. InVisualStudio,navigatetotheSubnavigationsublayout’scodebehind.
12. InthePage_Loadmethod,getthecontextitem’schildren(tripdetailsitems)asalist.
AddRendering
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 84
13. Bindthislisttoarepeater.Thereisapartiallycompletedcodesampleinthestudentresourcefolder
(WNDLabs>Module4>Topic4.1>LabA>Code>Subnavigation.ascx/Subnavigation.ascx.cs).
14. Foreachitemthathasbeenboundtotherepeater,outputastandard.NET
HyperLink
objectintothe
repeater’s
<ItemTemplate>
.
IMPORTANT!Forthepurposesofthislab,setthe
NavigateURL
propertyto#
CodeSampleItemProperties

<li>
<asp:HyperLinkText="[ITEMNAME]"NavigateUrl="#"runat="server"/>
</li>
Tip
YoudonotneedtousetheOnItemDataBoundpropertyforthisexercise.
Thesamplecodeusesastronglytypedrepeater
ItemType="Sitecore.Data.Items.Item".
Thismeansthat
youcanusethefollowingsyntaxtooutputpropertiesoftheobject,forexample,theparentIDofthe
item.Notethecolonafterthe#.ThisautomaticallyescapesanyHTML.
<%#:Item.ParentID%>

15. Save.
16. Usingabrowser,navigateto:http://BasicSitecore/FamilyHolidays.ConfirmthattheSubnavigation
componentnowappearsandthatitislistingthechilditemsbyitemname:
Extend
ContentAPICookbook
http://sdn.sitecore.net/upload/sitecore6/64/content_api_cookbook_sc64_and_latera4.pdf
DataDefinitionAPICookbook
http://sdn.sitecore.net/Reference/Sitecore%207/Data%20Definition%20API%20Cookbook.aspx

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 85
ItemLinks
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
ExplainwhattheItemResolverdoes.
ExplainwhattheLinkManagerdoes.
ResolveaURLtoanitem.
ResolveanitemtoaURL.
UseURLoptionstooutputaURLinacontextlanguage.
CustomizeLinkManager.
Content
TheItemResolver
 
KnowledgeCheck
WhatissuedoyouseewithduplicateURLsforthesameitem?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 86
LinkManagerandItemURLs
 
DemoRetrievinganItem’sURL
1. UsingVisualStudio,openasublayout,suchasIntroduction.ascx,andaddaLiteralcontrol.SettheID
toItemUrl.
2. Openthatsamesublayout’scodefile,forexample,Introduction.ascx.cs.
3. InthePage_Loadmethod,useSitecore.Links.LinkManager.GetItemUrl()toretrievetheURLofthe
contextitemasastring,andsetthe.TextpropertyoftheLiteralcontroltothisvalue.
CodeSampleRetrievingItemURL
LinkManager.GetItemUrl(Sitecore.Context.Item);
4. Inthesamefile,beforeretrievingthecontextitem’sURL,createaUrlOptionsobjectandsetthe
UseDisplayNamepropertytotrue.
5. PasstheobjectintotheSitecore.Links.LinkManager.GetItemUrl()methodalongwiththecontextitem.
CodeSampleRetrievingItemURL
UrlOptionsoptions=newUrlOptions();
options.UseDisplayName=true;
6. Browsetoapagecontainingthesublayoutthatyouedited.TheURLofthecontextitemisdisplayedas
astring.
7. UsingtheSitecoreDesktop,opentheContentEditorandlocatethe/sitecore/content/Home/Family
Holidaysitem.
8. Changetoanotherlanguage,forexample,Danish.
Inthefollowingdemo,wewill:
RetrieveitemURLusingLinkManager.GetItemUrl()
UseUrlOptionstooutputdisplayname
ChangeitemdisplaynameinSitecore
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 87
9. SelecttheHometab>DisplayNamecommand,andchangethedisplaynametoferier.
10. ThecontenttreewillrefreshanddisplaytheDanishwordforholidaysinthetreeaswellasinthe
contentpane.Notetheoriginalitemnameinsquarebracketsnexttothedisplayname.
11. Changethelanguagebackandnoticethattheitemdisplaynamechangesagain.
12. Inyourbrowser,changethecontextlanguagetothelanguageyoupreviouslysetthealternativedisplay
namein.Use?sc_lang=querystringattheendoftheURLinthebrowser’saddressbar.
13. PresstheENTERkeyonthekeyboard.TheLiteralcontrolnowdisplaysaURLcontainingthewordferier.
ControllingYourURLs
TipMediaItemURLS
Noticethatweareinstantiatinga
MediaItem
objectthatacceptsaregular
Item
.The
MediaItem
classisa
wrapperthatallowsyoutoaccesspropertiesthatareonlyrelevanttomediaitems,suchasitsextension,
orwhetherornotit’sfilebased.
stringpath="/sitecore/medialibrary/images/example";
Itemitem=Sitecore.Context.Database.GetItem(path);
MediaItemmediaItem=newMediaItem(item);
MediaUrlOptionsoptions=newMediaUrlOptions();
options.MaxWidth=200;
stringurl=MediaManager.GetMediaUrl(mediaItem,options);
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 88
ApplyTopic4.210min
RenderItemLinks
LabA. RenderingSubnavigationLinks
1. InVisualStudio,opentheSubnavigationsublayoutthatyoucreatedinanearlierlabandopenthe.ascx
file.
2. Withintherepeater,usethe
Sitecore.Links.LinkManager.GetItemUrl()
methodtooutputeachrepeater
item’sURLastheHyperlinkcontrol’s
.NavigateURL
property.
3. Withinthe
GetItemUrl()
method,useaninstanceof
UrlOptions
tospecifythattheURLsshouldcontain
theitem’sdisplaynames.
Tip
Youcandoallofthisononeline.
CreateanewURLOptionsobjectinsidetheGetItemURLmethod:
newSitecore.Links.UrlOptions{PropertyName=x})
4. Saveandsolutionandthenbrowsetothehttp://BasicSitecore/FamilyHolidayspage.Confirmthatyou
cannowusetheSubnavigationlisttonavigatetotripdetailssubpages.

Inthefollowinglab,youwill:
ModifytheSubnavigationsublayoutthatyoucreatedinthepreviouslabtooutputitem
links.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 89
Creating,Modifying,andDeletingItems
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describetheimplicationsofchoosingthecorrectdatabasetoretrieveanitemfrom.
Choosethecorrectusertoperformanoperationonanitem.
Placeanitemintoaneditablestate.
Createanitemprogrammatically.
Updateasimpleitemviaitsrawvalue.
Makeamodifieditemliveonthewebdatabase.
Content
FieldsandRawValues
GettingandSettingValues
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 90
DemoOutputtingRawValues
1. InSitecoreRocks,doubleclickanitemtoopenit.Selectanitemthathasapopulatedimagefield,such
asachildof/sitecore/content/Home/FamilyHolidays.
2. RightclickinagreyareabetweenfieldsandselectRawValues.
3. NoticethatthevalueiscustomXML,andnotanimagetag.
4. UsingVisualStudio,openanexistingsublayout’scodebehind(forexample,Introduction.ascx.cs).
5. InthePage_Loadmethod,retrievetheHeadingfieldasaFieldobject:
CodeSampleFieldobject
FieldheadingField=Sitecore.Context.Item.Fields["Heading"];
stringheadingValue=headingField.Value;
6. BindthevalueofthefieldtoaLiteralcontrol.
7. Inabrowser,previewapagethatutilizesthesublayout,thenswitchtoPageEditor.
Notethatthevalueisnoteditable.Thisisbecausewehaveoutputarawvalueratherthanarendered
value.
KnowledgeCheck
Whymightitbedifficulttosetthevalueofanimageorlinkfieldwhenyououtputrawvalues?
CreatingandEditingItems
Inthefollowinglab,youwill:
ViewrawvaluesofitemsinRocks
OutputrawvaluetothebrowseritwillnotbeeditableinthePageEditor
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 91
SecurityandEditingContexts
CodeSampleUserSwitcher
if(User.Exists(user.Name)){
using(newUserSwitcher(user)){}
}
Tip
Editing.EndEdit();returnsaboolthatindicateswhetheryouritemwassuccessfullysaved.Italsohassome
overloadsthatallowyoutosaveinasilentmanner,withoutraisinganyevents.Thiscanbeusefulwhen
modifyinganitemaspartofanevent,soyoudonotendupcreatinganendlessrecursion.
DemoCreatingandeditinganitem
1. InVisualStudio,locateanexistingsublayout(forexample,Introduction.ascx).
2. CreateabuttonwithanOnClickevent.
3. IntheOnClickevent,createanewitembasedontheTripDetailsdatatemplatebeneaththe
/sitecore/content/Home/FamilyHolidaysitem:
CodeSampleCreatingandEditinganItem
using(newSecurityDisabler())
{
//Youshouldcreatenewitemsinthemasterdatabase
Databasemaster=Sitecore.Configuration.Factory.GetDatabase("master");
ItemholidayParent=master.GetItem("/sitecore/content/home/FamilyHolidays");
In
thefollowingdemo,wewill:
ProgrammaticallycreateanitembasedontheTripDetailstemplate
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 92
//GettheIDofthedatatemplate,andcheckthatitemnameisvalid
IDsitecoreID=newSitecore.Data.ID("{565A8A17032F44ACB506B65F27A31241}");
TemplateIDtemplateID=newTemplateID(sitecoreID);
stringname=ItemUtil.ProposeValidItemName("CycletheCotswolds");
//.Addwillreturnthenewlycreateditemasanobject
ItemnewItem=holidayParent.Add(name,templateID);
//Editthisnewitem'sfields
newItem.Editing.BeginEdit();
Fieldheading=newItem.Fields["Heading"];
heading.Value="Ourfantasticholidays";
newItem.Editing.EndEdit();
Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item),false);
}
4. Savethesolution.
5. Usingabrowser,navigatetoapagethatcontainsthesublayoutwiththebuttonthatyoucreated.Click
thebuttonandyourcodewillexecute.
6. Browsetothenewlycreateditem(/FamilyHolidays/CycletheCotswolds).
RecommendedPractices
Donothardcodereferencestotemplates.Useacentralizedclass(forexample,TemplateReferences.cs)
withstaticpropertiesfortemplateGUID.
KnowledgeCheck
Ifyoucreateaniteminthemasterdatabase,whatneedstohappenbeforeitwillbevisibleonthesite?
TipCreatingaTemplateIDObject
SitecoredefinesanIDclassthatacceptsastringorGUID:
IDsitecoreID=newSitecore.Data.ID("{565A8A17032F44ACB506B65F27A31241}");
TemplateIDacceptsanIDobject:
TemplateIDtemplateID=newTemplateID(sitecoreID);
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 93
RecommendedPractices
TipDeletingItems
Youcandeleteanitemusingitem.Recycle()oritem.Delete().Usingitem.Recycle()
willmovetheiteminSitecore’srecyclingbiniftheRecycleBinActivesettingintheweb.configissetto
true.Ifthissettingissettotrue,item.Delete()willredirecttoitem.Recycle().
TipPublishingItems
Whenyoucreateordeleteanitemprogrammaticallyinthemasterdatabase,thechangeswillnot
appearinthewebdatabaseunlessyoupublish.Youroptionshereare:
Publishprogrammatically
Waitforascheduledpublishingtasktopublishtheentiretree
Iftheitemgoesintoaworkflow(coveredinModule9),waitforittobemanuallyreviewedand
approvedbyamoderator
ApplyTopic4.330min
CreateandEditItems
AcommonexampleofwhenyoumightwanttocreatenewSitecoreitemsprogrammaticallyisa
commentingsystem(forexample,allowinganonymousvisitorstocommentonparticulartripstheyhave
beenon).Inthefollowinglabs,youwill:
CreateaCommentdatatemplate.
CreateaCommentsSubmissionsublayoutwithaform,andassignittotheTripDetails
templatestandardvalues.CreateabuttonOnClickactionthatcreatesanewitem.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 94
LabA. CreateCommentDataTemplate
1. UsingSitecoreRocks,createaCommentdatatemplatewiththefollowingfields:
Fieldsection
Comment
Fieldname
Fieldtype
CommentAuthor
Singlelinetext
CommentText
RichText
2. Assignatemplateicon(forexample,user1_message.png).
3. Saveandpublishthedatatemplate.
KnowledgeCheck
Inthisinstance,youmightnotneedtoassigntheCommentdatatemplateasaninsertoptionon
theTripDetailsdatatemplatestandardvalues.Whynot?
KnowledgeCheck
Whatwouldhappenifyoubrowsedto:/holiday1/comment1?
LabB. CreateaCommentsFormSublayout
1. CreateanewsublayoutcalledCommentsForm(useAdd>NewItemandselectRenderings>
SublayoutfromtheSitecoremenu).
2. Createstandard.NETforminputsforCommentAuthorandCommentText.Thereissamplecode
availableinthestudentresourcesfolder(WNDLabs>Module4>Topic4.3>LabB>Code>
CommentsForm.ascx).
3. AssignthesublayouttothemaincontentplaceholderontheTripDetailsdatatemplatestandard
values.
4. PublishSitecore.
5. ConfirmthattheformappearsoneveryinstanceoftheTripDetailsdatatemplate.
LabC. CreateCommentItemsfromFormInputs
1. OpenCommentsForm.ascx.cs.YouwillfindapartiallycompletedcodesamplewithanOnClick
method(btnSubmit_Click)inthestudentresourcesfolder(WNDLabs>Module4>Topic4.3>LabC>
Code>CommentsForm.ascx.cs).
FortheremainingstepsinLabCandLabD,commentsareavailableinCommentsForm.ascx.cstoguide
you.
Finally,wireuptheformso
thatsubmittingitcreatesanewitem,beneaththecontexttripdetailsitem,
basedontheCommentdatatemplate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 95
2. Inthebutton’sOnClickmethod,startbyretrievingthecontextitemfromthemasterdatabase
(considerusingSitecore.Configuration.Factory.GetDatabase().Inthisparticularcase,theitemwillbeof
typeTripDetails.
KnowledgeCheck
Whyareyougettingthecommentfromthemasterdatabaseinthisinstance?
3. Havingretrievedyourintendedcommentsparent(thecontexttripitem),wrapyouritemcreationcode
inaninstanceofSitecore.SecurityModel.SecurityDisabler.
KnowledgeCheck
IsthereanothermethodthatyoucoulduseinsteadofSitecore.SecurityModel.SecurityDisabler?Whyisit
notbestpracticetouseSecurityDisabler?
4. Usethe.Add()methodonthetripitemthatyouretrievedfromthemasterdatabasetoinsertanew
commentitemasachild.ThismethodwillreturnanItemobject.
5. SetthetemplateparametertotheCommentstemplateyoucreatedinLabA.
Tip
CreateaSitecoreIDobjectfromthetemplate’sGUID,andthenusethattocreateaTemplateIDobjectthat
the.Add()methodcanaccept.
6.Setthenameparametertothecurrentdate/timeinISOformat.UsetheSitecore.DateUtil.IsoNow
property.
7.Savethesolution.
8.Browsetoatrippageandsubmittheform.
9. ConfirmthatchilditemsappearunderthecontextTripDetailsitem.Unlessyoupopulatedthedata
template’sstandardvalues,thecommentitems’fieldswillnotcontainanydata.
LabD. PopulateCommentsItemwithFormValues
1. AfterusingtheAdd()methodtocreateanewitem,puttheresultingiteminaneditingstateusingthe
.Editing.BeginEdit()method.
2. SettheCommentAuthorandCommentTextfieldvaluestothecorrespondingforminputvalues.At
thispoint,youmaywanttouseHttpUtility.HtmlEncode()tosanitizeyourinput.
CodesampleRetrievingFieldValue
item.Fields["CommentAuthor"].Value=CommentAuthorInput.Text;
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 96
KnowledgeCheck
Giventhatallfieldvaluesarestoredasstrings,whycan’tyousettheCommentDatefieldvaluetoa
DateTime.Now?
3. FinisheditingbycallingtheEditing.EndEdit()method.
4. Savethesolution.
5. Browsetoatrippage,fillinandsubmittheform.
6. InSitecoreRocks,confirmthatthechilditemscreatedunderthecontexttripnowcontainyourform
content.
Extend
InformationonprogrammaticallypublishingisintheAPIcookbook‐section2
http://sdn.sitecore.net/upload/sitecore6/64/content_api_cookbooka4.pdf

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 97
WorkingwithComplexFields
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describethecorrectwaytoretrievecomplexfieldvalues.
Getandsetcontentincomplexfields.
UseImageField,LinkField,ReferenceFieldandMultilistField.
RenderfieldsusingtheFieldRenderer.
Content
RECAP:FieldTypes
SimpleFields
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 98
ComplexFields
BaseFieldObject
ImageFieldobject
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 99
BestPractice
Donotmanuallyconstructan<img.src=""/>tagfromanImageFieldobjectandrenderittothepage
becausethevalueswillnotbeeditableinPageEditor.
LinkFieldObject
BestPractice
Donotmanuallyconstructan<ahref=""/>tagfromaLinkFieldobjectandrenderittothepage.The
valueswillnotbeeditableinPageEditor.
ReferenceFieldobject
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 100
MultilistFieldObject
SomeFieldsCanBe‘Rendered’
FieldRenderer.Render()
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 101
Parameters
ImageParameters
Parameter
Propertyaffected
W
Width
H
Height
mw
MaxWidth
Mh
MaxHeight
La
Language
Vs
Version
Db
Database
Bc
BackgroundColor
as
AllowStretch
sc
Scale(floatingpoint)

RecommendedPractice
AlwaysgothroughtheFieldrenderermethodwhenyouarerenderingfieldcontenttothescreen.This
methodallows:
YourfieldtobeeditableinPageEditor.
Overridepropertiestobespecifiedbytheauthor(forexample,theClassonalinkorthe
Widthonanimage).
LinksinRichTextfieldstobetransformedintoSEOfriendlyURLs.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 102
Demo–UsingFieldRenderer
1. UsingVisualStudio,opentheIntroductionsublayout’scodebehind.
2. InthePage_Loadmethod,rendertheMainImagefieldandbindtheresultingstringtoaLiteralcontrol.
3. PassinanumberofparametersthatarerelevanttoImagefields(forexample,maxwidthandmax
height[mw=200&mh=100]).
4. Showthattheseparametersarerepresentedaspropertiesonanimagecontrol.
ApplyTopic4.450min
PopulateandRenderComplexFields
LabA. PopulateaCommentLinkField
1. UsingSitecoreRocks,locatetheCommentdatatemplateandaddthefollowingadditionalfield:
Fieldsection
Comment
FieldName
Field
CommentAuthorWebsite
GeneralLink
2. UsingVisualStudio,openCommentsForm.ascxandaddatextboxinputforalink.Thereissample
codeforthisadditionalfieldinthestudentresourcefolder(WNDLabs>Module4>Topic4.4>LabA>
Code>CommentsForm.ascx).Donotoverwritethecontentsofyourfile;insertthesample.
3. OpenCommentFormsublayout’s.csfile.RetrievetheCommentAuthorWebsitefieldasaLinkField
objectwherethecommentitem’sfieldsarebeingpopulated(between.BeginEditand.EndEdit).
4. Wewanttherenderedoutputtolooklikethis:http://www.sitecore.net/.Setthefollowingpropertieson
theLinkFieldobject:
Objectproperty
Objectvalue
.URL
Thecontentsofthelinkinput(e.g.
AuthorWebsite.Text)
.Text
The
same
contentsofthelinkinput
(http://www.sitecore.net/)
.Target
"_blank"
.LinkType
"external"
5. SaveandpublishSitecore.
6. Browsetoatripdetailspage,fillinandsubmittheform.
Inthefollowingdemo,wewill:
UsetheFieldRenderer.Render()methodwithafewparameterstooutputanimagefield.
Inthefollowinglabs,youwill:
AddaGeneralLinkfieldtoyourCommentdatatemplatethatacceptsthecomment
author’swebsite.
Createanewsublayoutthatrendersalistofcommentsatthebottomofpagesbasedon
theTripDetailstemplate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 103
7. SwitchtoSitecoreRocksandlocatethenewlycreatedcomment.Confirmthatthelinkfieldis
populatedwiththeformcontent.
LabB. RenderListofComments
1. CreateanewsublayoutcalledCommentsList.PastesampleHTMLforthecommentslistinthestudent
resourcesfolder(WNDLabs>Module4>Topic4.4>LabB>HTML>campaignpagecomments.html).
RemembertoappendthissampleHTMLtothecontentalreadyintheCommentsListsublayout.Donot
overwritethedirectivesandincludeitatthetopofthefile.
2. AddthenewsublayouttothestandardvaluesoftheTripDetailsdatatemplate,belowtheComments
Formsublayout:
3. SaveandpublishSitecore.
4. BrowsetoatripdetailspagetoconfirmthatthesampleHTMLappears.
5. ReplacethedummyHTMLwitharepeater.Asamplerepeaterisavailablein(WNDLabs>Module4>
Topic4.4>LabB>Code>CommentsList.ascx).
6. OpentheCommentsList.ascxcodebehind.
7. InthePage_Loadmethod,retrievethecontextitem’schildrenandfilteritsothatonlyitemswiththe
Commentdatatemplateareincluded.
8. Bindthislisttotherepeater.
Tip
Use.Where()tocompareeachitem’s.IDtotheIDoftheCommenttemplate:
.Where(x=>x.TemplateID==MyTemplateIDObject))
Intherepeater,useSitecorecontrols(forexample,<sc:Text/>)tooutputthefollowingfieldvalues:
a. CommentAuthor(Text)
b. CommentText(Text)
c. CommentAuthorWebsite(Link)
d. Datecreated(Date__Createdfielduse
Sitecore.FieldIDs.Created
toretrievefieldand
consideringexperimentingwiththeFormatattribute).
Foreachcontrol,setthe
DataSource
attributetotherepeateritem’sIDproperty.Thisforcesthecontrol
todrawitscontentfromthatparticularcommentitemasopposedtothecontextitem.
In
thefollowinglab,youwill:
Bindalistofcommentstoarepeaterandoutputtheauthor’sname,webaddress,and
comment.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 104
Tip
JustasinTopic4.1,weareusingastronglytypedrepeater.IfyouareusingSitecorecontrolsinthe
repeater,seteachcontrol’sDataSourcepropertytothefollowing:
DataSource="<%#:Item.ID%>"
Notethecolonusedaboveinthebindingexpressions:<%#:%>,byaddingthecolonthedatabeing
boundisautomaticallyHTMLencoded.
Savethesolution,thenuseabrowsertopreviewaTripdetailspage.Usetheformtoaddafewcomments.The
finalcommentslistshouldlooklikethis:
KnowledgeCheck
Whenyousubmitacomment,whyisitonlyvisibleinPreviewmode?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 105
AdvancedPresentation
Concepts
Contents:
ReusableComponents
LayoutDeltas

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 106
ReusableContent
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Defineadatasource.
Retrievethedatasourcefromacomponent.
Describethebenefitsofusingparameters.
Setandretrieveparameters.
DescribewhattheParseURLParametersutilitydoes.
Content
DemoWhatIsaDatasource?
BusinessUseCase
Whatifyouhaveaquotescomponentthatdisplaysthesamequoteonanumberofdifferent
pages?
Withoutdatasources,youmustdefinethosequotefieldsoneverysingleitemwhereyouwantto
displaythisquote.Thisresultsincontentduplication.
Whatifyouhaveanumberofquotesthatyouwanttodisplayononepage,forexample,onthe
bottomrightandonthetopleft?
Withoutdatasources,youmustdefineseveralfieldswithsimilarnamessothatyoucantargeteach
fieldindividually,aswellasseveralsimilarcomponents(forexample,QuoteTitle1,QuoteTitle2,
QuoteAuthor1,QuoteAuthor2resultinginfieldduplication).
Withdatasources,youhaveonelocationinthetreewithyourquoteitems.Yourquotecomponent
acceptsadatasourceofoneormoreofthoseitemsanddisplaysthem,resultinginnoduplication.
1. LogintothePageEditorinterfaceinTraincore,andensurethatdesignmodeisenabled.
2. ChangethedatasourceofaGeneralWidgetcomponentonthehomepagetoanotheritemunder:
/sitecore/content/sitecorecyclingholidays/Global/reusablecontent.
3. Navigatetothewhichbikepage.AddaGeneralWidgettotheleftorrighthandcolumnofthepage.
4. Setthedatasourcetothesameitemyouusedonthehomepage.

Inthefollowingdemo,wewill:
UsingTrainCore,inPageEditordesignmode.
ChangeaGeneralWidget’sdatasource.
AddanadditionalGeneralWidgettothepage.
Illustratethereuseofcomponentsandcontent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 107
KnowledgeCheck
Whatkindofcontentcanbeglobalcontent?
WhatIsaDatasource?
DatasourcesAllow…
BestPractice
ItisbestpracticetouseIDsinsteadofpaths.Iftheitemgetsrenamedorchangeslocation,theIDwill
preventabrokenlink.WhenauserselectsadatasourceintheUI,SitecoreinsertsanIDbydefault.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 108
TipXSLTsandWebControls
InXSLT,the$sc_itemvariablerepresentsthedatasource.Noadditionalconfigurationisrequired.Ifno
datasourcehasbeenspecified,$sc_itemdefaultstothecontextitem.Bycontrast,$sc_currentitem
alwaysreturnsthecontextitem.
Similarly,thereisabasewebcontrolclassnamedSitecore.Web.UI.WebControlthatprovidesthe
GetItem()methodtoretrievethedatasourceitem.
UsingtheAPIforSublayoutDatasources
KnowledgeCheck
WhatIfyouneedtogetthedatasourceforseveralcomponentswhichyouwillwhatcouldyoudowith
thiscode?
ForcingControlstoUsetheDatasource
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 109
DemoDatasourceAPI
1. Openhttp://BasicSitecore,andlogintothePageEditorinterface.LocateapagethatdisplaystheTrip
Overviewcomponent.Changethedatasourceofthecomponenttoanothertrip.
2. Save,andthenswitchtoVisualStudio.
3. InthecodebehindfortheTripOverviewcomponent,wireupthetwoSitecorecontrolstoreadtheir
contentfromadatasource.Asabonus,ifnodatasourceexists,fallbacktothecontextitem.
GiveeachSitecorecontrolanID.
Inthecodebehind,retrievethis.Parent(theusercontrol’sparent)andcastitasa
Sitecore.Web.UI.WebControls.Sublayoutobject.Thisobjectwrapstheusercontrol,andis
Sitecorespecific.
Set.Itemor.DataSourceofeachSitecorecontroltothedatasourceprovidedbytheSublayout
object.
Tip
Youcanthencheckifthecomponenthasadatasource.Ifitdoes,thendisplayit,otherwisereturnthe
contextitem.
Tip
Whatifyourcomponentalwayshadtoacceptadatasource?Youcanhideyourcontrolsbychecking
whatmodethepageisusinginSitecore.Context.PageModethenperformingyourlogic.
4. Save,andswitchtothePageEditor.
5. VerifythattheSitecorecontrolsareoutputtingcontentfromthechosendatasource,notthecontext
item.Changethedatasourceagaintoconfirm.
Tip
YoucanuseSitecoreRockstosetthedatasourceofacomponent.Selectthecontentitemwhose
presentationdetailsyouwishtoedit,andpressCTRL+U.Doubleclickthecomponentwhosedatasource
youwishtochange,andclicktheellipsistochooseacontentitem.
Inthefollowingdemo,wewill:
ModifytheTripDetailscomponenttoacceptadatasource.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 110
ComponentRenderingParameters
RetrieveRenderingParametersUsingtheAPI
DemoParameters
1. Openhttp://BasicSitecoreinthePageEditor,andlocateapagethatdisplaystheTripOverview
component.Ensurethatdesigningmodeisenabled.
2. InVisualStudio’sSolutionExplorer,openTripOverview.ascx.ChangethecolorfortheTripOverview
tablefromgreytoredbymodifyingtheHTMLtoincludearedclass.Inorderforanauthortobeableto
dothis,thisvalueneedstobecomearenderingparameter.Saveandreloadthebrowsetoseethe
changeincolor.
3. SwitchbacktothePageEditor,andclicktheTripOverviewcomponenttoselectit.
6. Inthefloatingtoolbar,selectMore>EditPageEditorOptions.
7. IntheParametersfieldatthebottomofthedialog,addCssClassasakey,andredasavalue.ClickOK,
andsavethepage.
Inthefollowingdemo,wewill:
ChangethebackgroundcolorfortheTripOverviewcomponentfromgreytoredusingrendering
parameters.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 111
8. SwitchtoVisualStudio’sSolutionExplorer,andopenTripOverview.ascx.cs.
9. Inthisfile,retrievethecomponent’srenderingparametersasastring(use
((Sublayout)Parent).Parameters).
10. ConvertthestringtoaNameValueCollectionobjectusingthe
Sitecore.Web.WebUtil.ParseUrlParameters()method.
11. ExtractthevalueoftheCssClasskeythatyouspecifiedearlier,andsetittoapublicproperty.
12. OutputthatpublicpropertyinTripOverview.ascxinthefollowinglocation:
Codesample
<divclass='indentedSection<%=CssClass%>'>
13. Save.
14. SwitchtothePageEditorandreloadthepage.ConfirmthatredisbeingoutputintheHTMLsource,
andthattheTripOverviewnowhasaredbackground.
WhereShouldIDefinePresentationandDatasources?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 112
ApplyTopic5.140min
BuildaFeaturedTripComponent
LabA. CreateComponentandgettheDataSourceItem
1. CreateasublayoutnamedFeaturedTrip.
2. PastethefollowingsampleHTMLintothe.ascxfile.Alternatively,copyfromStudentResourcesFolder
>WNDLabs>Module5>Topic5.1>featuredtrip.html:
CodeSample

<divclass="indentedSectionwidgetfillred">
<divclass="indentedSectionInner">
<h2>ExploreHolland</h2><!‐‐Headingfield‐‐>
<imgsrc="img/forestcyclist.png"style="width:100%"/><!‐‐MainImagefield‐‐>
<p>Anexcellenttourofthecountry.</p><!‐‐MainContentfield‐‐>
</div>
</div> <p>Anexcellenttourofthecountry.</p><!‐‐MainContentfield‐‐>
</div>
</div>
3. WhereindicatedbycommentsintheHTML,useSitecorecontrolstooutputthefollowingfields:
Heading
MainImage
MainContent
4. GiveeachcontrolanID.
5. SettheMainImagemaxwidthto280.MaxWidthisapropertyonthe<sc:Image/>control.
6. Savethesolution.
7. UsingSitecoreRocks,addtheFeaturedTripcomponenttothemaincontentplaceholderontheFamily
Holidaysitem,(inthiscasenotinthestandardvaluesyoumightnotwantthecomponenttoappear
everytimeyoucreateaholiday).
8. SelectthesublayoutandopenthePropertieswindow.YoucanalsoopenthePropertieswindowby
pressingF4,ordoubleclickingthecomponent.
9. SettheDataSourcepropertytoanytripdetailsitem.
10. SaveandpreviewtheFamilyHolidaysitem,usingCommandy.
11. Confirmthatthecomponentisoutputtingdatafromthecontextitem.Wehavetoexplicitlytellthe
controlstooutputdatafromthedatasource.

Intheselabsyouwillbuildareusable
FeaturedTrip
componentthatacceptsatripdetailsdatasourceand
canbestyledusingparameters.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 113
12. InthePage_LoadmethodofthefeaturedFeaturedTrip.ascx.csfile,getthecomponent’sdatasource
usingthefollowingcode:
CodeSampleDatasource

varsublayout=ParentasSublayout;
vardatasource=sublayout.DataSource;
13. IntheFeaturedTrip.ascx.csfile,setthe
.DataSource
propertyofeachcontroltothedatasourceitem.
14. ClicktheSavebuttontopublishthesolution.
15. Previewthepageandconfirmthatthecontentisnowcomingfromthecomponent’sdatasourceitem
ratherthanthecontextitem.
LabB. RetrievetheCssClassParameterValue
1. UsingSitecoreRocks,navigatetotheFamilyHolidayspagewhereyouaddedtheFeaturedTrip
component.
2. IntheDesignLayoutpane,doubleclicktheFeaturedTripcomponenttoopenitsProperties.
3. ClicktheEllipses(...)buttonnexttotheParametersproperty.
4. AddapropertycalledCssClassandgiveitavalueofred.YouwillbeinjectingthisvalueintheFeatured
Tripcomponent’sHTML.
5. InFeaturedTrip.ascx.cs,getthecomponentparametersasastring(use
((Sublayout)Parent).Parameters
).
6. ConvertthestringtoaNameValueCollectionobjectusingthe
Sitecore.Web.WebUtil.ParseUrlParameters()method.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 114
7. ExtractthevalueoftheCssClasskeythatyouspecifiedearlierandsetittoapublicpropertywithin
yourclass:
CodeSamplePublicProperty
publicstringCssClass
{
get;
set;
}
8. OutputthatpublicpropertyinFeaturedTrip.ascxinthefollowinglocation:
CodeSampleOutputPublicProperty

divclass='indentedSection<%=CssClass%>'>
9. Savethesolution.
10. BrowsetotheFamilyHolidayspageandconfirmthattheindentedSectionhasanadditionalclassthatis
beingpulledfromyourcomponent’sparameters.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 115
LayoutDeltas
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Definethepurposeofalayoutdelta.
Content
WhatAreLayoutDeltas?
ALayoutDeltaIsLikeaTransform
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 116
TheRenderLayoutintheRequest

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 117
RealWorldSolutions
Contents:
FamiliarConcepts
DealingwithLargerSites
SitecoreQuery

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 118
FamiliarConcepts
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
DescribearealisticSitecoreprojectsetup.
Describearealisticcontenttree.
Describerealisticdatatemplateandpresentationconfigurations.
Createandconfigureanewdevice.
Content
DemoSolution,Topology,andTemplates
VisualStudioProjects
TheTraincoreprojectfoldersitsoutsidethewebroot(moreontheprosandconsofworkinginsidethewebroot
inModule9).
ThecoreoftheapplicationlivesinTraining(Training.csproj).
LikeallASP.NETprojects,commonorsharedfunctionalityhasbeenabstractedintothree
additionalprojects:
o Training.Utilities
o Training.Controls
o Sitecore.Utilities(canbereusedwithanySitecoreproject)
VisualStudiopublishingprofilesareusedtomovefilesfromtheprojectintotheSitecoreweb
root.RightclickinthetoolbarandselectWebOneClickPublishtoenablethepublishprofile
dropdown.
References
Referenced.dllsarestoredinaLibrariesfolderintheprojectroot.NotethatCopyLocalissettofalse,incase
youinstallTraincoreintoadifferentversionofSitecorethanthereferenced.dll.YoucouldsetupalocalNuGet
serverwithinyourcompanyandstoredifferentversionsoftheSitecore.dllsthere.
Configuration
IntheVisualStudioproject,thereareanumberofsmallerconfigurationfilesinside/App_Config/Includesuch
asBaseCore.Sites.configorBaseCore.Search.config.Thesepatchchangesintotheweb.config,soyoucanavoid
keepingtrackofchangestoweb.config,whichisalreadyhuge.
Browsetohttp://traincore/sitecore/admin/ShowConfig.aspx.Thispageallowsyoutoseethefinalpatched
web.config.(MoreonthissubjectinModule9.)
Inthefollowingdemo,wewilllookat:
Traincore’sprojectstructure.
Traincore’sSitecoretreestructure.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 119
SitecoreContent
LogintotheContentEditorandexpandTraincore’smainsitetree:/sitecore/content/sitecorecyclingholidays.
Therearetwositesinthisinstallation:
Sitecorecyclingholidays
Sitecorecyclingholidayscorporate
Wewillcovermultisiteimplementationsinalatertopic.
Homeisthesiteroot.TraincorehasseveralothernonwebsitefoldersincludingGlobalunder:
sitecorecyclingholidays.
Globalcontainssmallchunksofreusablecontentthatareusedasdatasourcesbycomponents,
suchasgalleryslidesandGeneralWidgetcontent(under:/Global/resusablecontent).
Globalalsocontainstheentiresite’snavigationasatreestructureunder:/Global/navigation.
Bookingsisabucketofunstructuredholidaybookingitems.(MoreinthisinModule8).Thisisa
samplesite,anditisunlikelythatyouwouldbuildyourownecommercesysteminSitecoreso
considerproductssuchasuCommerceforSitecore.
TheSettingsitemunder:/sitecore/Contentisforcontentthatissharedacrossallsitessuchas
renderingparameteroptions(moreonthisinModule7).Mostofthiscontentusesshared
fields,whichmeansthecontentisidenticalacrossversionsandlanguages.
Traincore’stemplatesinheritmultiple,smallerbasetemplatesthereisn’tasingle‘base’.This
isbecausecertainpages,suchasthehomepage,donotrequirea‘Heading’or‘MainContent’
field.Werecommendthatyouavoidredundantfieldsthatdon’toutputanything.
Tip
Traincoredefinesmainandfooternavigationinaseparatefolderunder:/Globalratherthangeneratingit
fromthesitestructure.Thisisamuchmoreinexpensivequery;itallowsyoutoincludeexternallink
itemsandmakesiteasytoseeataglancewhatthesite’snavigationisgoingtolooklike.
RecommendedPractices
Allitemfieldsshouldhaveaneffect.Anauthorshouldnotfillinandpublishafieldwithoutseeinga
result.Thismakesthesiteappearbroken.
RecommendedPractices

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 120
DrawIt
Thetrainingsitehasalotofnestedcomponents,bothstaticallyanddynamicallydefined:
Containerswithplaceholdersthatdividepagesintohorizontalslices.
Columnsincludingonecolumn,twocolumn,andthreecolumnfunctionalcomponents.
DemoPresentationConfiguration
1. UsingVisualStudio,expandthelayoutsfolder.Notethenumberandvarietyofsublayouts.
2. Open/layouts/BaseCore/containers/and/layouts/BaseCore/columns.Therearemanymoreplaceholders
inthissolutionthantheBasicSitecoresolutionfromModules15.ThisisbecauseTraincoremakesuse
ofsublayoutnestingtobuildupavarietyofpagedesigns.
Important
Youcanonlyuseoneinstanceofaplaceholderonapage.Forexample,ifyouhaveusedtheGallery
Container(whichdefinestheGalleryContainerkey),youcannotaddanadditionalGalleryContainer
becauseyoucannottargetitsplaceholderasecondtime.
3. Logintohttp://traincore/,andselectthePageEditorinterface.
4. DirectlyunderHome,createanewpageofthetypeStandardContentandnameitFavoriteBikes.
5. EnsurethatdesignmodeisenabledontheViewtab.
6. Thepageisdividedintocontainers.Bydefault,StandardContentitemshaveaHeader,Page,and
Widgetscontainer.InsertanewGalleryContainercomponent.
7. Intothegallerycontainerplaceholder,insertaBannercomponentchooseadatasourcewhen
prompted.Notethattheselectiontreestartsunderthegalleriesitem,andthatincompatibleitemsare
greyedout.MoreonthisinModule7.
8. SelecttheWidgetsContainercomponent,andmoveitabovethePageandGallerycontainers.Splitting
apageintocontainersallowsfordesignflexibility.
9. InsertanewGeneralWidgetintothewidgetcontainerplaceholderandselectadatasourceforit.
10. ClickMore>EditComponentProperties,andchangesomeofthevalues,suchasClassandWidget
Width.Usingrenderingparametersallowsyoutoapplymanydifferentstylestothesamecomponent.
AlthoughtheStandardContentdatatemplatehasadefaultpresentation,wecancompletelychangethelook
andfeelusingahierarchyofnestedcomponents.
Inthefollowingdemo,wewilllookat:
Presentationdetailsofvariousitemsandparticularlyhowsublayoutsarenested.
Whichcomponentsacceptdatasources.
Whichcomponentsmakeuseofrenderingparameters.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 121
PlaceholderNestingandComponentReuse
SupportingthePageEditor

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 122
DemoCreateaMobileSite
1. UsingSitecoreExplorer,openTraincoreandcreateanewdevicenamedMobileunder:
/Traincore/master/sitecore/Layout/Devices.
2. ViewthepresentationdetailsofanyitemandnotethatMobilenowappearsasadeviceoptioninthe
DeviceManager.
3. UsingSolutionExplorer,createanewlayoutcalledMobile.Youwillbepromptedtocreatealayout
definitioniteminSitecore.
4. UseSitecorecontrolstooutputthePageHeadingandPageContentfieldsinsidethe.aspx.Inthis
example,wewillnotbeusinganystyles.
5. Addaplaceholdercontroltothebottomofthepageandnameitskeywidgets.
6. Saveanddeploythesolution.
7. AssignthenewlayouttotheBattleoftheHillsitem(under:/sitecore/content/Home/sitecorecycling
holidays/holidays/battleofthehills)ontheMobiledevice.AddanumberofwidgetstotheWidgets
placeholder.
8. OpentheBattleoftheHillsiteminPageEditor.UsetheExperiencetabtochangethedevicebetween
DefaultandMobile.Notethatthecontentbeingdisplayedisthesameasthecontentusedbythe
Defaultdevice.
RecommendedPractices
TherearethreemainapproachestoSitecoreandmobile:
StandardResponsiveDesign
Usetheresponsivedesignbyitself,withoutusinganySitecoredevicesatall.Sitecorewillnotinterfere.
Thismeanslittleextraworkforbackenddevelopers,andgivestheresponsibilitytothefrontend
developers.
However,ignoringdevicesmeansthatyoucannotpersonalizecontentbasedondevice,andlargepages
withmanycomponentsmaynotlookasgood.Youwillalsoneedtotestallcombinationsofcomponents
thatanauthormightuse.
Inthefollowingdemo,wewill:
Createamobiledevice
CreateandassignasimpleMobilelayouttoaholidayitem’sMobiledevice
OutputPageHeadingandPageContentinthelayout
Addanumberofexistingcomponents(alsousedbytheDefaultdevice)totheMobile
layout’splaceholder.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 123
Devices
Youcaneithercreateanentirelyseparatesetofpresentationdetailsforyourmobiledeviceorusethe
samepresentationdetailsinadifferentconfiguration,andrelyonresponsivedesignforformatting.
Thefirstapproachallowsyoutousethesamecontent,butcompletelydifferentcomponentsorCSSto
stylesharedcomponents.Whilethisallowsyoutotargetmobiledevicesspecifically,youmayfindthat
youneedtomaintaintwosetsofcomponentsand/orstylesheets.

Thebenefitsofthesecondapproacharethatwhileyouarerelyingonresponsivedesigntoformatyour
sitebasedonscreensize,youcanchoosetousemoreorlesscomponents,andusetheminaslightly
differentorder.Responsivedesignisstillresponsiblefortheappearanceofyoursite,butyoucancutout
excessivecomponentstoimprovetheexperience.
SeparateSite
Finally,ifitsuitsyourrequirements,youcancreateanentirelyseparatemobilesite(muchlikesitecore
cyclingholidayscorporate)withseparatecontent.
Devices

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 124
ApplyTopic6.160min
NewsArticlePage
CreateaNewsArticleDataTemplateandStandardValues
LabA. CreateaNewsArticledatatemplate
1. UsingSitecoreRocks,createanewdatatemplatecalledNewsArticleunder:
/sitecore/templates/BaseCore/Pages.
KnowledgeCheck
AnewsarticlepagerequirescommonfieldssuchasPageHeadingandMetaDescription.Giventhatthis
isafunctioningsiteandthesefieldshavealreadybeendefinedinabasetemplate,howwouldyouadd
themtotheNewsArticletemplateyouhavejustcreated?
In
thissetoflabs,youwillcreateanewsarticlepagefromadesignandspecificationsuppliedbySitecore
CyclingHolidays.
SitecoreCyclingHolidaysisbuildinganewssectionandhaveaskedyoutoworkonthe
newsarticletemplate.Newsitemsaregoingtobecreatedunderthenewslisting:
http://traincore/news.
Thecurrentnewssectionusesstandardcontentpages:http://traincore/news/ourplans
forthenewyear.
Thenewsarticlepagewilllooksimilartothestandardcontentpage,butwithanews
specificfeaturerelatedarticles.
Inthefollowinglabsyouwill:
CreateaNewsArticledatatemplate,configureitsbasetemplatesandaddanumberof
additionalfields.
CreatetheNewsArticletemplate’sstandardvalues.
ConfigureNewsArticleasaninsertoptiononNewsListing.
CreateandpopulateanumberofitemsbasedontheNewsArticletemplate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 125
2. Selectthefollowingbasetemplates:BasePage,BasePageContent,andBasePageSummaryImage.
Tip
Ratherthanfindingcommandsusingmenus,youcanrightclickandselecttheCommandyoption,or
presstheCTRL=SHIFT=SPACEkeysonthekeyboardtobringuptheCommandytoolbar.Commandy
allowsyoutosearchforyourcommandbyname(forexample,BrowseorPageEditor)andexecuteitin
thecontextyouarein(forexample,withaparticularitemselected).
3. AddanadditionalfieldunderafieldsectioncalledArticle:
KnowledgeCheck
Whyshouldyouinheritfrombasetemplatesratherthanrepeatfieldsonindividualtemplates?
4. SetthesourceoftheRelatedArticlesfieldtothepathoftheNewsListingcontentiteminthetree
(/sitecore/content/sitecorecyclingholidays/Home/news).Thisallowsustochoosefromthenewsitem’s
childrenintheRelatedArticlesmultilist.
5. SetthetemplateicontotheNewsAddicon(searchforortypeNetwork/16x16/news_add.png).
LabB. CreatetheNewsArticlestandardvalues,assigninsertoptions,andcreateanarticle
1. CreatetheNewsArticletemplate’sstandardvalues.
2. Onthetemplate’sstandardvalues,checkthatthe$nametokenappearsinPageTitle,PageHeading,
andNavigationTitle.
3. NavigatetotheNewsListingtemplate’sstandardvaluesandsetNewsArticleasaninsertoption.
4. UsingSitecoreRocks,createseveralnewitemsbasedontheNewsArticletemplateunder:
/sitecore/content/sitecorecyclingholidays/home/news.
Tip
Usethe‘createmultipleitemsfunctionalityinSitecoreRocks.InthebottomlefthandcorneroftheAdd
NewItemdialog,increasethenumberofitemstocreatefrom1to5ormore:
FieldName
FieldType
Article
Related
Articles
Multilist
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 126
5. Populateeachitemwithsamplecontent.Foreacharticleitem,selecttwoormorerelatedarticlesinthe
RelatedArticlesMultilist.
6. Thefollowingwillappearatthetopofeachnewsarticleitem:
In
Sitecore,workflowisahighlyconfigurableapprovalprocessthatitemsgothroughbeforetheyappear
onthelivesite(forexample,tomakesurethatnewsarticlesthathavenotbeenapprovedbythenews
teamdonotappearonthesite).
7. Toapprovethenewsarticle,clicktheHometab,thenclickthearrownexttotheEditbutton>Clickthe
Submitoptionasdetailedbelow.WewillcoverworkflowinmoredetailinModule9.
8. Smartpublishthedatabaseandthenbrowsetothenewspagetomakesurethatyournewitemsare
beingdisplayedinthenewslist.
KnowledgeCheck
Clickonthelinktoyournewsitem.Youshouldseeanemptypage.Whycan’tyouseetheThelayoutfor
therequesteddocumentwasnotfound’?
CreateaComponentandBindittothePlaceholder
LabA. CreateaRelatedArticlesSublayout
1. UsingVisualStudioSolutionExplorer,rightclickthe/layouts/BaseCore/content/folderandselectthe
Add>NewItem…option.InsertanewsublayoutcalledRelatedArticles.
Inthefollowinglabsyouwill:
AddtheTwoColumnsublayouttotheNewsArticle’sstandardvalues.
CreateasublayouttooutputthecontentsoftheRelatedArticlesfield.
Bindyoursublayouttoaplaceholder.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 127
2. UsetheSitecoresectiontoinsertasublayoutandnameitRelatedArticles.
3. WhenpromptedbySitecoreRocks,addthecorrespondingsublayoutdefinitionitemto
/Traincore/master/sitecore//layout/Sublayouts/BaseCore/Content/.
Tip
Ifyouarenotpromptedtoaddasublayoutdefinitionitem,yourprojectmightnotbeconnectedtoa
Sitecoreinstance.Rightclicktheproject,selecttheSitecore>Connect…optionandpicktheSitecore
instancethatyouwanttouse.
4. Asamplerepeaterhasbeenprovidedinthestudentresourcesfolder(WNDLabs>Module6>Topic6.1>
LabC>Code>RelatedArticles.ascx).Copyandpastethiscodeintoyour.ascxandthensave.
Donotoverwritetheentirefilebecausethesampleonlycontainsthecodefortherepeater.
5. NavigatetotheNewsArticletemplate’sstandardvaluesandopentheDesignLayoutpane.
6. Copypresentationdetailsfromstandardvalueswhenprompted.
Copyfromstandard
values
Presentationdetailsfrom
standardvalues
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 128
7. Addthe2followingsublayouts,andassignthemtotheplaceholderkeysasshowninthefollowingtable.
TwoColumnContentisapreexistingsublayout.
8. Savethesolution.
9. Becauseweareworkingoutsidethewebroot,weneedtodeploythechangedfiles.Todeploy,right
clickontheVisualStudiotoolbarandselectWebOneClickPublish.Dependingonyoursetup,thismay
alreadybechecked.
10. Apublishtoolbarwillappear.DonotconfusethiswithSitecorepublishing!
11. SelecttheTraincoreprofile,andclicktheglobeicontodeployyourfiles.Thisprofileissetupaspartof
theTraincoreinstallationprocess.Iftherearen’tprofilesavailable,pleasenotifyyourinstructor.
KnowledgeCheck
WhenyouuseaSitecorecontrolandspecifyafieldforexample:
<sc:Textfield="PageHeading"runat="server"/>
,whatitemdoesthecontroldefaulttoasitsdatasource?
LabB. OutputaListofRelatedArticles
1. UsingVisualStudio,openRelatedArticles.ascx.cs.
KnowledgeCheck
LookintheSitecore.Data.Fieldsclass.Whichfieldobjecttypewouldbemostsuitableforretrievingthe
RelatedArticlesfieldfromthecontextitem?
2. InthePage_Loadmethod,retrievetheRelatedArticlesfieldonthecontextitemasa
MultilistField
object.
3. Usethe
GetItems()
methodonthe
MultilistField
objecttoretrievealistofselecteditems.Theseitems
representrelatedarticlesyouchoseoneacharticle.
KnowledgeCheck
Whatwouldthe.ValuepropertyoftheRelatedArticlesfieldobjectcontain?
KnowledgeCheck
Whywouldn’tyouuseFieldRenderer.Rendertooutputthecontentsofamultilistfield?
Renderingname
Placeholder
TwoColumnContent
PageContainer
RelatedArticles
TwoRightColumn
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 129
4. Bindthelistofitemstotherepeater.
5. Thesamplerepeater’s
<ItemTemplate>
promptsyoutoaddaSitecorecontrol.Replace[SITECORE
CONTROL]withaSitecoretextcontrolthatoutputsthePageHeadingfield.
CodeSample
<ItemTemplate>
<li><ahref="[URLHERE]">[SITECORECONTROL]</a></li>
</ItemTemplate>
6. Becausethecontrolisinarepeater,wewanttotellittoretrievethePageHeadingfromeachrepeater
itemandnotfromthecontextitem.Todothis,setthetextcontrol’s
DataSource
propertytotheitem’s
ID.(Notetheuseofthe
<%#:Item.ID%>
syntaxbecausetherepeaterisstronglytyped;
Item
represents
anobjectoftype
Sitecore.Data.Items.Item
):
CodeSample
DataSource="<%#:Item.ID%>"
7. ThesamplerepeateralsopromptsyoutoaddaURL.Replace[URLHERE]withamethodthatretrieves
theSEOfriendlyURL.(Hint:refertoModule4ifyouareunsureofwhichmethodtouse).
CodeSample
<ahref="
<%
#:YOURMETHOD(Item)
%>
">

8. Saveanddeploythesolution.
9. Previewanewsarticlepage.Thecomponentintherighthandcolumnnowdisplaysalistoflivelinksto
therelatedarticlesspecifiedintheRelatedArticlesMultilist.
NewsArticlePage

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 130
DealingwithLargerSites
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Listthreeconsiderationsthatmustbetakenintoaccountwhenarchitectingamultilanguage
site.
Namefourlanguageconfigurationsandwhattheydo.
Accountforitemswithoutversions.
Configureamultisitesolutioninweb.config.
Listthelimitationsofamultisitesolution.
Content
MultiLanguageSupport
Remember!
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 131
DemoMultisite
1. UsingtheSitecoreRocks,expandthe/sitecore/contentiteminTraincoreandlookatthetwosites
sitecorecyclingholidaysandsitecorecyclingholidayscorporate.
2. PreviewtheHomeitemofeachsite.Theyusethesamepresentationdetailsindifferentconfigurations,
andthecorporatesiteissignificantlysmaller.
Contentisindependent,butpresentationanddatatemplatesareshared.Bothsiteshave
exactlythesamefunctionality.
Youcouldhavetwoentirelydifferentsitesstoredinthesameimplementation(forexample,a
mobilespecificsite,takingadvantageofdevices).
3. IntheSolutionExplorer,openApp_Config/Include/BaseCore.Sites.config.Notethepresenceoftwo
<site>nodes.Notethatthesitehostname,language,startpathandstartitemdiffersbetweensites.
4. Browseto/sitecore/admin/ShowConfig.aspxtoseethefinal,transformedconfigurationfile.Locatethe
<sites>nodesagaintheyaremergedintothemain<sites>configurationsection.
5. OpenIISandselectTraincore.Addtraincorecorporatetothesite’sbindings,andmakesureitis
includedinyourhostsfile.
6. Browsetohttp://traincorecorporatetoseethelivesite.
7. Youcansharecontentbetweensitesusingcloning.IntheContentEditor,Selectthetermsand
conditionsitemunder/sitecorecyclingholidays/Home.YoucandothisinSitecoreRocksaswell,butthis
tasktendstobeperformedbyauthors.
8. Selecttheitem,andclicktheHometab>Duplicatedropdown>Clone:
9. Choose/sitecorecyclingholidayscorporate/Homeastheitem’snewparent.Notethatthecloned
item’snameisgreyedout.
10. Makeachangetotheclone’sPageHeadingfield.
11. GobacktotheoriginalitemandmakeachangetothePageHeadingofthisitem.
12. Gobacktotheclone.Ithaspickeduponthechangetotheparent,andofferstreechoices:

Inthefollowingdemo,wewill:
Lookattheconfigurationformultisite,andaddhttp://traincorecorporate/.
Createanitemclone.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 132
Multisite
Important
Becausethecorporatesiteisverysmallandreceivesverylittletraffic,itusesthesameapplicationpool
asthemainsite.Notethatmultiplesitesusingmultipleapplicationpoolshavelicensingimplications.
RecommendedPractices
Amultisiteinstallationisnotalwaysappropriate.Forexample:
Themorediscrepanciestherearebetweensitesinthesameinstallationthelargerandmorecomplexthe
codebasebecomesandthemoreconvolutedtheSitecoreconfigurationbecomes.
Whenallsitesusethesameapplicationpool,theperformanceofoneaffectsalloftheothers.
SitecoreCyclingHolidaysworksasamultisitesolutionbecausethesitesshareexactlythesame
functionality.Youwouldnotmixaholidaybookingsiteandaretailsitewithnothingincommon.
Extend
DictionaryDomains
http://www.sitecore.net/Community/TechnicalBlogs/JohnWestSitecore
Blog/Posts/2012/11/SitecoreASPNETCMS66FeaturesDictionaryDomains.aspx
ReusingandSharingData
http://sdn.sitecore.net/upload/sitecore7/70/reusing_and_sharing_data_sc70a4.pdf

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 133
SitecoreQuery
Introduction
Bytheendofthistopicyouwillbeableto:
WritesimpleSitecorequeriesusingavarietyofoperatorsandfunctions.
WriteSitecorequeriesthatuseaxes.
DiscussappropriateusesofSitecorequeryandwhentooptforthesearchAPI.
Content
Demo‐SitecoreQuery
1. UsingSitecoreRocks,opentheXPathBuilderbyrightclickinganywhereinyourtreeandselectingTools
>XPathBuilder.
2. Experimentwithvariousqueries(examplesbelow).Use/sitecore/contentasyourContextNode:
Absolutequery
/sitecore/content/#sitecorecyclingholidays#/*
Relativequery
.//*[@@templatename='Bike']
Filterbytemplate
/sitecore/content/#sitecorecyclingholidays#//*[@@templatename='Bike']
Filterbycontent
/sitecore/content/#sitecorecyclingholidays#//*[@#PageTitle#=
'News']
Returnatindex
/sitecore/content/#sitecorecyclingholidays#/*[3]
ancestororself::*
/sitecore/content/#sitecorecyclingholidays#/ancesto
r
o
r
self::*
ancestororself::[@@...]
/sitecore/content/#sitecorecyclingholidays#/Home/holidays/#battleofthehills#/ancesto
r
o
r
self::*[@@templatename='Holidays']
./ancestororself::*[@@templatename='Holidays'](Contextnode:/sitecore/content/sitecorecycling
holidays/Home/holidays/battleofthehills)
Parent
/sitecore/content/#sitecorecyclingholidays#/parent::*/child::*
Following
/sitecore/content//*[@@name='sitecorecyclingholidays']/following::*

Inthefollowingdemo,wewill:
PerformvariousqueriesontheTraincoretreeusingtheXPathBuilderinSitecoreRocks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 134
3. UsingSitecoreRocks,navigatetotheHolidaydatatemplateandlookattheTerrainfield.Notethe
presenceofanancestororselfquerythatreturnsallvaluesrelevanttothecontextsite.
4. GotoanitembasedontheHolidaydatatemplatetheselectionisrestrictedbythequery.
SitecoreQuery
Important
Queriesareusefulinamultisiteenvironmentwhenyouneedtogetitemswithoutusinga
pathorGUID.
QueriescanbeexpensiveWedonotrecommendusingqueriesinahightrafficenvironment.
Don’tquerytheentirecontenttree.
Notethatwhenyouusecomplexqueriesitmayaffectperformance.
TheresultsetwillbelimitedbytheQuery.MaxItemssettingintheweb.config.
Youhavetosorttheresultswhenyoureturnthem.
QuerySyntax
Specificpath
query:/sitecore/content/home/
Getsallimmediateitemsunder
home
Note:Useifthereisonlyonelocation,forexample:/settingsandwhensettingsissharedbyallsites
Cannotbeusedinamultisite.
*
wildcard
query:/sitecore/content/*/news
Getsitemsundercontent/[anything]
callednews
/
children
query:/sitecore/content/home/*
Getsallchildrenof
home
/followedbyGUID,itemname,or*
//
descendants
query:/sitecore/content//*[@@templatename=
'
News
'
]
Getsallitemsthathavehomeasancestorandhave
News
asthetemplatename
//followedbyGUID,itemname,or*
Note:Canbeexpensiveifthetreeislarge
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 135
@@
XMLattribute
query:/sitecore/content/[@@templatename=
'
NewsListing
'
]
Getsallitemsunder
/home
thatusethe
News
template
e.g.@@templatenameor@@templateid
Note:Casesensitive
@
field
query:/sitecore/content/*[@#PageTitle#=
'
Home
'
]
Getsanyitemsunder
/home
thathaveafieldcalled
PageTitle
andfieldvalueof
News
Note:Use#toescapespacesandhyphensinfieldnames
.
contextitem
Inthecaseofasourcefield,it’stheitemyouarecurrentlyviewinginthecontenttree
[1]
index
query:/sitecore/content/*[3]
Returnstheitemunder
home
atindex3
Note:It’snotazerobasedindex
UsesforSitecoreQuery
Tip
FormoreinformationonTreelistParameters,seep12:
http://sdn.sitecore.net/upload/sitecore6/datadefinitioncookbooka4.pdf

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 136
ApplyTopic6.310min
SitecoreQueryinDatasources
SetRelatedArticlesSource
1. UseSitecoreRockstoopen/master/sitecore/content/templates/BaseCore/Pages/NewsArticle.
2. Inthefarrighttextfield,nexttotheBuildbutton,buildaquerythatsatisfiesthefollowingconditions:

TheitemsmusthavethetemplateNewsArticle.
Theitemsmustappearunderthesameparentaseachother(NOTallitemsinthetreebasedon
theNewsListingitem.Forexample,ifthereare10articlesinyourtreeinthetree,yourquery
shouldonlyreturntheNewsArticleitemsthataresiblingsoftheoneyouarecurrentlylooking
at)(Hint:youarelookingforanyitemwhoseancestororself::hasatypeofNewsListing).
Extend
FastQuery
http://sdn.sitecore.net/upload/sdn5/developer/using%20sitecore%20fast%20query/using%20sit
ecore%20fast%20query001.pdf
http://www.sitecore.net/unitedkingdom/Community/TechnicalBlogs/JohnWestSitecore
Blog/Posts/2012/05/SitecoreQueryCheatSheet.aspx
ParameterizedDatasources
http://sdn.sitecore.net/upload/sitecore6/datadefinitioncookbooka4.pdf(Search:“Treelist
Parameters”)

Toensurethatthecorrectitemsarepickedinalistfield,restricttheselectiontoaparticularlocationand/or
templatetype.Thisisparticularlyimportantinmultisiteinstallations,whereeachsitemighthave
individuallocationsforlistcontent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 137
ConfiguringthePageEditor
Contents:
DatasourceRestrictions
ParametersandParameterTemplates
PlaceholdersRestrictions
AdvancedPageEditorConfiguration

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 138
DatasourceRestrictions
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Restrictthetypeofitemthatcanbeselectedasadatasource.
Restrictthelocationfromwhichanitemcanbeselectedasadatasource.
Content
DatasourceLocationandTemplateRestrictions
Tip
Anitemcanbeselectedfromanywhereinthetree,solocationrestrictionsdonotapply.Ifyourestrict
onlythedatasourcetemplate,thenitemsthatarenotselectablewillbeghosted(greyedout),and
authorswillnotbeabletoselectthem.
TheSelecttheAssociatedContentdialogwillnotpopupautomatically,butitcanbeaccessedviathe
SelectAssociatedContentbuttoninthatcomponent’sfloatingtoolbarinthePageEditor.
DemoApplyRestrictions
1. OpenthePageEditor,andensurethatthedesignmodeisenabled.
2. SelecttheGeneralWidgetcomponentandselectMore>EditPageEditorOptionsinthefloating
toolbar.
3. ClickInsertLinkabovetheDatasourceLocationfieldandselect/sitecore/content/sitecorecycling
holidays/Global/reusablecontent.ClickOK.

Inthefollowingdemo,wewill:
ApplydatasourcerestrictionsusingthePageEditor.
ViewdatasourcerestrictionsinSitecoreRocks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 139
4. AddasecondGeneralWidgetcomponent.
5. Apromptappears,askingyoutoselectassociatedcontent”.Selectadatasourceitem,andclickOK.
6. SelectthesameGeneralWidgetcomponent,andselectMore>EditPageEditorOptionsagain.
7. Thistime,clickInsertLinksabovetheDatasourceTemplatefieldandselect
/sitecore/Layouts/Sublayouts/BaseCore/GlobalContent/GeneralWidget.
8. AddanotherGeneralWidgetcomponenttothepage.NoticethatyounowhaveanoptiontoCreate
NewContentwhenyouarepromptedtoaddadatasource.Itemsthatdonotmatchtheselecteddata
template,suchastherootreusablecontentsitem,aregreyedout.
9. SelectCreateNewContent,givethenewdatasourceaname,suchasTheBestMountainBikes,andclick
OK.
10. Populatethecontentofthedatasourceinline,andSavethepage.
11. SwitchtoSitecoreRocks.
12. Navigatetothereusablecontentfolder,andnotethatthedatasourcenamedTheBestMountainBikes
wascreatedbehindthescenes.
13. Navigateto/sitecore/Layouts/Sublayouts/BaseCore/GlobalContent/GeneralWidget.Noticethatthe
DatasourceLocationandDatasourceTemplateareavailableinSitecoreRocksaswell.
ApplyTopic7.125min
DatasourceRestrictions
SetDatasourceLocation
1. LogintothePageEditorinterface.
2. Ensurethatyouareindesignmode.
3. NavigatetotheHomepage,andselectanyexistingGeneralWidgetcomponent.

4. Inthefloatingtoolbar,selectMore>EditPageEditorOptions.
5. ClicktheInsertLinkbuttonabovetheDatasourceLocationfield.
Inthefollowinglabsyouwilllearntousethe
PageEditor
torestrictthelocationandtypeofitemsauthors
canselectasadatasource.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 140
6. Intheitembrowserdialog,locateandselect:/sitecore/content/sitecorecyclingholidays/Global/reusable
content,thenclickOK.
AddaComponent
1. SelectAddNewComponentontheribbon.
2. AddanewGeneralWidgettothewidgetscontainerplaceholder.
3. TheSelectAssociatedContentdialogappears.NoticethattheCreateNewContenttabisgreyedout.
SelectanyitemfromthatlistandclickOK.
4. Savethepage.
SetDatasourceTemplate
1. SelecttheGeneralWidgetcomponentyoujustaddedtothepage.
2. SelectMore>EditPageEditorOptionsinthefloatingtoolbar.
3. SettheDatasourceTemplatefieldtopointto/sitecore/templates/BaseCore/GlobalContent/General
Widget.
AddAnotherComponent
1. AddanotherGeneralWidgetcomponenttothewidgetscontainerplaceholder.
2. NoticethattheCreateNewContentbuttonisnowavailableintheSelectAssociatedContentdialog.
Clickit,andgivethenewdatasourceaname,suchasNewBikesAvailable.ThiscreatesanewSitecore
iteminthebackground.
3. PopulatetheGeneralWidgetinline,andSavethepage.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 141
ParametersandParameterTemplates
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Createandassignaparametertemplate.
Describethebenefitstoanauthorofusingaparametertemplate.
Content
DemoUsingaParameterTemplate
1. InSitecoreRocks,createaparametertemplatebasedonStandardRenderingParameters.Nameit
RelatedArticlesRenderingParameters.
2. AddasamplesinglelinetextfieldnamedCSSClasstothetemplate.
3. AssigntherenderingparameterstotheRelatedArticlescomponent.
4. UsingthePageEditor,browsetooneoftheNewsArticleitemsyoucreatedinModule6.Selectthe
RelatedArticlescomponentandselectEdittheComponentProperties.
5. NotethepresenceoftheCSSClassfieldalongsideDatasourceandPlaceholder.
KnowledgeCheck
Whatproblemsmightyouencounterifyoudonotuseparametertemplates,andallowauthorstospecify
parameterkey/valuepairsthemselves?
SpecifyParametersUsingaParameterTemplate
Inthefollowingdemo,wewill:
CreateandassignaparametertemplateusingSitecoreRocks.
ShowtheresultinthePageEditor.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 142
ApplyTopic7.250min
ParameterTemplates
CreateandAssignParameterTemplate
1. UsingSitecoreRocks,navigateto:/master/sitecore/templates/BaseCore/Layouts/RenderingParameters
andcreateanewrenderingparameterstemplate.
2. RightclickandselecttheInsertaNewTemplate…option.
3. NamethenewtemplateRelatedArticlesRenderingParameters.
4. SetthebasetemplatetoStandardRenderingParameters.
5. NamethefirstsectionStylesandcreateafieldcalledClassofthetypeDroplinkandthesource
/sitecore/content/settings/styles/widgets.
KnowledgeCheck
GiventhatyouwillprobablyhavealimitedsetofCSSclassesthatyouwanttoreuseacrossthesite,
whatmightbeagoodchoiceforfieldversioning?
6. NavigatetotheRelatedArticlessublayoutthatyoucreatedinModule6:
/master/sitecore/layout/Sublayouts/BaseCore/Content/RelatedArticles.
7. FindtheParametersTemplatefieldintheEditorOptionsfieldsection,andclicktheBrowsebutton.
8. LocateandselecttheRelatedArticlesRenderingParameterstemplatethatyoucreatedinstep2.
9. Savethesublayout.
10. UsingthePageEditor,navigatetooneofthenewsarticlethatyoucreatedearlier.
SelecttheRelatedArticlecomponentandinthefloatingtoolbarandclicktheMorebuttonandthenthe
EdittheComponentPropertiesoption.
11. ConfirmthattheClassfieldnowappearsintheComponentPropertieswindow.
Inthefollowinglabsyouwill:
Createaparametertemplate.
Assignaparametertemplatetoacomponent.
UsethePageEditortosetparametersonacomponent.
Outputthecontentsoftheparameterfield.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 143
12. SelectredfromtheClassdropdownlistandclickOKandSave.
UseParametersinCode
1. UsingVisualStudio,navigatetotheRelatedArticlesublayoutandopenthe.csfile.RefertoModule5
forcodesamples.
2. Retrievethesublayoutparameters.
3. ReturntheClassparameter.
4. Theparametertemplateyoucreatedearlierdefined“Class”asadroplink.ThevalueoftheClass
parameterisgoingtobeaSitecoreIDasastring.
5. ConvertthisstringtoaSitecoreIDanduseittoretrievethe
referenceditem.
6. ThereferenceditemhasafieldnamedCSSClasses.Retrievetheraw
valueofthisfieldasastring,andmakeitavailableasapublic
property.
7. Inthe.ascxfile,usecodeblockstooutputtheClassstring
<div
class="chunkwidget">
(Besuretoleaveaspace).
8. SaveandDeploytheVisualStudiosolution.
9. BrowsetothenewsarticlewiththeRelatedArticlecomponentand
confirmthatthiscomponentnowhasthestylespecifiedinthe
ParameterTemplatefield.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 144
PlaceholderRestrictions
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describethepurposeofaplaceholdersettingsitem.
Explainwhatcompatiblerenderingsare.
Content
PlaceholderSettingsItems
Tip
Tocreateaplaceholdersettingsitem,insertanewitemunder:/sitecore/Layouts/PlaceholderSettings.
MakesurethePlaceholderKeyfieldispopulate.Werecommendthatyouuselowercaseforthe
placeoholderitemnameandkey,becausethismakesiteasiertoidentifyasaplaceholderinthe
componenthierarchy.
Tip
Usethe
WebEdit.PlaceholdersEditableWithoutSettings
settinginweb.configtomakeallplaceholders
selectableeveniftheydonothaveaplaceholdersettingsitem.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 145
CompatibleRenderingsandAllowedControls
DemoAllowedControlsandCompatibleRenderings
CompatibleRenderings
1. OpenthePageEditor,andensuredesignmodeisenabled.
2. OntheHomepage,selecttheGallerycomponent.Youmayneedto
clickthebluearrowtonavigatetothegallerycomponentitself.
NoticethepresenceofaniconcalledReplacewithcompatible
rendering.
3. SelectBannerwhenprompted,andsave.Ratherthanascrollinggallerywithmultipleimages,younow
haveasingleimage.
4. ReplacetheBannercomponentwiththeGallerycomponentagain.
5. SelecttheBannercomponentagainand,inthefloatingtoolbar,clickthebluearrowtonavigatetothe
componentsplaceholder(gallerycontainer).
AllowedControls
1. InthePageEditor,browsetothenewsarticleyoucreatedearlierunder:/sitecore/content/sitecore
cyclingholidays/Home/news
2. Selectthetworightcolumnplaceholder,whichisthenarrowcolumnwithintheTwoColumnContent
sublayout.Clickthepenciliconinasquaretoedittheplaceholdersettings.
Inthefollowingdemo,wewill:
UsetheCompatibleRenderingsbutton.
Assignallowedcontrols.
Assigncompatiblerenderings.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 146
KnowledgeCheck
Whycan’tauthorsaddRelatedArticlestotheplaceholder?
3. ClickEditnexttotheAvailableControlsmultilist,andaddRelatedArticlestotherighthandside.Click
OK.
4. SelectthetworightcolumnplaceholderagainandclickAddtohere.AddRelatedArticlestothepage.
ConfiguringCompatibleRenderings
1. Remainonthenewsarticlepage,inthePageEditorinterface.SelecttheRelatedArticlescomponent
andselectMore>EditPageEditorOptions.
2. ScrolldowntotheCompatibleRenderingsfield.LocatetheSubnavigationcomponent(thepathis
/sitecore/layout/Renderings/BaseCore/Subnavigation).Doubleclickthecomponenttomoveitintothe
righthandcolumn,thenclickOK.
3. SelecttheRelatedArticlescomponent.Noticethatthecompatiblerenderingsbuttonappearsinthe
floatingtoolbar.Clickit,andselectSubnavigationasareplacementforRelatedArticles.
KnowledgeCheck
IfyouselecttheSubnavigationcomponent,whyistherenowaCompatibleRenderingsbutton?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 147
AdvancedPageEditorConfiguration
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Createacustomexperiencebutton.
Createaneditframe.
Content
WalkthroughCustomExperienceButtons
1. InthePageEditor,ensuredesignmodeisenabledandselectanycomponent.Notethevarietyof
buttonsthatappearonthefloatingtoolbar.Eachofthesebuttonsfiresacommand.Thesecommands
areconfiguredinthecoredatabase.
2. SwitchtoSitecoreRocks.Openthecoredatabaseandnavigateto:
/sitecore/content/Applications/WebEdit/DefaultRenderingButtons/Delete.Doubleclicktoopenit.Thisis
whereSitecore’sdefaultbuttonslive.
3. IntheEditorpane,changetheTooltipfieldfrom“Removecomponent”to“Deletecomponent”.
4. SwitchbacktothePageEditor.Refreshthepage.Selectthesamecomponent,andhoveroverthe
Deletebutton.Notethatthetooltiptexthaschanged.
5. YoucancreateyourownbuttonsorusesomeofSitecorepreexistingones.Onthefloatingtoolbar,click
More>EditPageEditorOptions.
6. InthePageEditorButtonsfield,selectanumberofadditionalcontrols.ClickOK,refreshthepage,and
confirmthatthenewbuttonsappear.
Inthe
followingwalkthrough,wewill:
Changeanexistingbuttononthefloatingtoolbarforallcomponents.
AddanadditionalcustomexperiencebuttontothefloatingtoolbaroftheGeneral
Widgetcomponent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 148
7. SwitchbacktoSitecoreRocks.ThebuttonyoujustselectedcomesfromtheCustomExperience
Buttonslistinthecoredatabase.Navigateto:/sitecore/content/Applications/WebEdit/CustomExperience
Buttons.Youcaninsertyourowncustomexperiencebuttonshere.
CustomExperienceButtons
Tip
Commandsarelistedinthe/App_Config/Commands.configinthefilesystem.Theyhaveanameandan
associatedtype,andinheritfrom:Sitecore.Shell.Applications.WebEdit.Commands.WebEditCommand.
TypesandHowtoAssignThem
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 149
EditFrames
DemoEditFrames
1. UsingSitecoreRocks,navigateto:/core/sitecore/content/Applications/WebEdit/EditFrameButtons
2. DuplicatetheDefaultfolderandrenameittoHolidaySummary.
3. OpentheHolidaySummaryitemandchangetheDefaultTitlefieldtoHolidaySummary.
4. DeleteallexcepttheEdititem,whichisbasedontheFieldEditorButtontemplate.
5. OntheEdititem,changetheHeading,FieldsandTooltipasfollows.
6. Openthebascorewidgetholidaysummary.ascxsublayout:/layouts/BaseCore/widgets/basecore
widgetholidaysummary.ascx.
7. SurroundtheentiredefinitionlistHTML(seecodesamplebelow)inthelistwithan
<sc:EditFrame/>
.
Inthefollowingwalkthrough,wewill:
CreateaFieldEditorbutton.
InsertaneditframeintotheHolidaySummarywidget.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 150
8. SettheButtonsIDtotheIDoftheHolidaySummaryfolderitemyoucreatedinthecoredatabase.
CodeSampleEditFrame
<sc:EditFrameID="EditFrame1"Buttons="/sitecore/content/path/to/buttons"runat="server">
<dl>
<!‐‐...‐‐></dl>
</sc:EditFrame>
9. Saveanddeploythesolution.
10. SwitchtoPageEditormodeandnavigatetoaholidaypage,forexample,BattleoftheHills.
11. SwitchonEditing,butswitchoffDesigning.
12. Clickthewhitespacewithintheholidaysummarylist.Youreditframewillappeararoundthecontent.
13. Clickthecommandonthefloatingtoolbar.Yourfieldswillappearinapopupwindow.
ApplyTopic7.415min
EditFrame
AddanEditFrame
1. UsingSitecoreRocks,navigateto/core/sitecore/content/Applications/WebEdit/EditFrameButtons.
2. DuplicatetheDefaultfolderandrenameittoHolidaySummary.
3. OpentheHolidaySummaryitemandchangetheDefaultTitlefieldtoHolidaySummary.
4. DeleteallexcepttheEdititem,whichisbasedontheFieldEditorButtontemplate.
5. OpentheEdititem.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 151
6. ChangetheHeading,FieldsandTooltipasfollows.
7. SwitchtoVisualStudio.
8. Openthebascorewidgetholidaysummary.ascxsublayout‐/layouts/BaseCore/widgets/basecore
widgetholidaysummary.ascx.
9. SurroundtheentiredefinitionlistHTML(seecodesamplebelow)withan
<sc:EditFrame/>
.
10. SettheButtonspropertytothepathoftheHolidaySummaryfolderitemyoucreatedinthecore
database.
CodeSampleEditFrame
<sc:EditFrameID="EditFrame1"Buttons="/sitecore/content/path/to/buttons"runat="server">
<dl>
<!‐‐...‐‐>
</dl>
</sc:EditFrame>
11. Saveanddeploythesolution.
12. SwitchtoPageEditormodeandnavigatetoaholidaypageforexample,BattleoftheHills.
13. SwitchonEditing,butswitchoffDesigning.
14. Clickthewhitespacewithintheholidaysummarylist.Youreditframewillappeararoundthecontent.
15. ClicktheCubescommandinthefloatingtoolbar.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 152
16. TheTerrainfieldopensupinapopupwindow.
KnowledgeCheck
IftheDataSourcepropertyisnotset,wherewilltheeditframetrytoretrievethefieldvaluesfrom?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 153
DealingwithYourData
Contents:
ItemBuckets
Search
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 154
ItemBuckets
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
ExplainhowbucketssolveUIconcernsinlargeimplementations.
Createbucketsandbucketableitems.
Configurebucketsettingsandfacets.
Usethebucketsinterfacetosearchforandmanagecontent.
Content
TheScenario
WalkthroughUsingBucketsasanAuthor
1. UsingtheDesktopinterface,opentheContentEditor.
2. RightclickthequickactionbarandselectItemBucket.Thiswillhighlightitemsinthetreethatare
buckets.
3. Navigateto/sitecore/Content/sitecorecyclingholidays/Bookings.
4. ClicktheSearchtabandtype*toshowallresults.
5. Typemar*inatoshowthatwildcardsworkasexpectedyoucanalsouse“?”inplaceoftheasterisk.
Inthefollowing
demo,wewill:
Usebuckettosearchforbookings.
Narrowdownresultsusingfacets.
Editandcreateitemsasnormal.
Useplaintextsearchtosearchforawidgetweknowexists,forexample,whichbike.Use
wildcards,replacements,andexactphrases.
ChangetheresultsviewtoGalleryorGUIDview.
Replicatesearchmechanismintheircodequeryanindexratherthanatree.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 155
6. Clickasearchresulttoopenit.Duplicateittomakesurethatthefunctionalityisnormal.Clickthe
Searchbuttontorefreshthesearchandtheduplicateditemshouldappear.
Notethelistoffiltersintherightcolumnonthescreen.Theseareknownasresultfacets(forexample:
bydefault,SitecorefacetsonTemplateNameandLanguage).
7. Inourresultslist,wehaveaHolidayBookedfacetthathasbeencreatedespeciallyforTraincoreto
narrowdownbookingresultsbyholidaypackagebooked.Clickthearrowonthelefthandsideofthe
searchbox.Noticethatsearchfiltersandbulksearchoperationsbecomeavailabletoyou:
WhatIsaBucket?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 156
WhentoUseaBucket
Tip
Totestfunctionalityandperformance,youcanusetheFillDBpagefoundintheadminfoldertoquickly
createlargeamountsoftestdata,totestthebucketsfunctionalitywithsampleURL:
http://TrainCore/sitecore/admin/filldb.aspx
DemoBucketsandBucketableItems
1. IntheContentEditor,selecttheReusableContentitemandclicktheConfiguretab.
2. ClicktheBucketbutton.TheoptionsintheBucketschunkshouldhavechangedtoRevertandSync,and
aSearchtabwillappearinthecontentpane.
3. Thisitemisnowabucket.Ifyouwantallitemsbasedonthistemplatetobebuckets,setitonstandard
values.
4. Navigatetothestandardvaluesitemofthedatatemplate.ClicktheConfigure>Bucketoption.
5. Createanewitembasedonthisdatatemplate.Thebucketiconshouldappearinthegutternexttoit,
denotingthatitisabucket.
6. Enablestandardfields,andscrolltotheItemBucketsfieldsection.Additionaloptionsincludelimiting
whichviewsareallowedfortheitem(forexample,GalleryViewforimageheavyitems),orchoosingto
maintainparent/childrelationshipswhenbucketingapreexistingsubtreeofitems.
7. Navigatetothereusablecontentitemandtrysearchingfor*.Althoughyouseeresults,ifyouexpand
thereusablecontentitem,itschildrenallappearasnormalitemsbecausetheitemshavenotbeenmade
bucketable.
8. Selectoneofthechildrenofthereusablecontentitem.Noticethemessageatthetopoftheitem:
Inthefollowingdemo,wewill:
Turnreusablecontentintoabucket.
MakeGeneralWidgetitemsbucketable.
Changebucketsettings.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 157
9. Navigatetotheitem’sdatatemplateandcreateastandardvaluesitemifonedoesnotexist.
10. Onthedatatemplate’sstandardvalues,findtheItemBucketsfieldsection,andselecttheBucketable
checkbox.
11. Savetheitemandnavigatebacktothebucket.
12. Becauseyouhavemadechangespertainingtothebucketabilityofitemsinthereusablecontent
bucket,youmustsyncit.Notethatyoudonotneedtosyncabucketaftermakingcontentchanges.
OntheConfiguretab,clicktheSyncbutton.Thebucket’schildrendisappear.
13. OntheViewtab,selecttheBucketscheckbox.Thenexpandthereusablecontentitem.Notetheitems
areorganizedbycreationtime;yoursearchesactuallyrunagainstanindexoftheseitems.
Note
Anyitemcanbecomeabucket;itemsinbucketsshouldbebucketable.Youcanmixnonbucketableitems
in,buttheywillnotbehaveinthesameway.
Tip
Youcanmakeaparticulartemplateabucketbydefaultbyselectingthetemplate’sstandardvaluesand
clickingtheBucketcommandontheribbon.
CreatingaBucket
Tip
Topreservetheparent/childrelationship,navigatetothestandardvaluesofthetemplateoftheitem
thatwillactastheparent(forexample:itemsbasedontheNewsArticletemplatewillbetheparentto
itemsbasedontheCommenttemplate.).EnsurestandardfieldsarevisibleandselecttheLockChild
Relationshipcheckbox.
Tip
SpecifyaFacetFilterclasstofacetononlycertainitemsforexample:youmaywanttoexcludesome
languages.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 158
Tip
Toviewthefolderstructureunderabucket,clickView>Bucketsoption.Thisisconfigurablein
Sitecore.Buckets.config:
<settingname="BucketConfiguration.BucketFolderPath"value="yyyy\/MM\/dd\/HH\/mm"/>
MakingItemsBucketable
DemoConfiguringFacets
1. UsingtheContentEditor,navigateto:/System/Settings/Buckets/Facets.
2. NavigatetotheFileTypefacet.ThefieldisExtension.
3. NavigatetoamediaitemintheMediaLibrary;oneofthefieldsiscalledExtension.Thisisaverysimple
mappingbetweenSitecorefieldandindexfield.
4. NavigatetotheLanguagefacet.NotetheFieldNamefield;thiscorrespondstoafieldintheindex,not
inSitecore.Noticethatitemsdonothavealanguagefield,eveninrawvalues.Thisiscalculatedand
enteredintotheindex.
Developerscanextendthefacetlist,butitisnotassimpleasfacetingonanyfieldwithoutdoingsome
preprocessing.HowdoyoufacetonapipedelimitedlistofIDs?
5. NavigatetotheHolidayNamefacet.Noticethatthefieldnamehereiscomputedholidayname.Thisis
anothercalculatedfield.WhentheindexerlooksatSitecoreitems,itlooksateveryitemandseesifit
livesunderaholidayitem,thenaddsthatholiday’snametothiscustomfield.
Inthefollowingdemo,wewill:
Viewanumberofpreexistingfacetscreatedbydevelopers.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 159
SearchFacets
ApplyTopic8.120min
CreateaBucketandMakeItemsBucketable
TurntheNewsListingTemplateintoaBucket
1. UsingtheContentEditor,navigatetotheNewsListingtemplate:
/sitecore/templates/BaseCore/Pages/NewsListing.Makesurethatyouareviewingstandardfields.
2. Selectthetemplate’sstandardvalues;thenclicktheConfiguretab>Bucketschunk>Bucket
commandtoturnitintoabucket.
3. Navigatebacktoanexistingnewslistinginthecontenttree:/sitecore/content/sitecorecycling
holidays/Home/news.
4. Confirmthattheitemisnowabucket.TheactivecommandsintheBucketschunkshouldbeRevertand
Sync.
KnowledgeCheck
ExpandtheNewsitem.Whyarethenewsarticleitemsnothidden,eventhoughthenewsitemhasbeen
turnedintoabucket?
Inthefollowinglabs,youwill:
TurnitemsbasedontheNewsListingtemplateintobuckets.
MakeitemsbasedontheNewsArticletemplatebucketable.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 160
MaketheNewsArticleTemplateBucketable
1. UsingtheContentEditor,navigatetotheNewsArticletemplate:/sitecore/templates/BaseCore
/Pages/NewsArticle.
2. Selectthetemplate’sstandardvalues(makesureyouareviewingstandardfields).
3. NavigatetotheItemBucketsfieldsectionandselecttheBucketableCanbestoredasan
unstructurediteminanitembucketcheckboxandsave.
4. Becauseyouhavemadeachangetothetemplateofanitemthatappearsinabucket,youmustsync
existingbuckets(theexistingnewsitem).
5. Selecttheexistingnewsiteminthecontenttree.
6. Confirmthatallchildren(exceptourplansforthenewyear,whichisbasedontheStandardContent
template)arehiddenandthatsearchandfacetingworkasexpected.
Extend
Developer’sGuidetoItemBucketsandSearch
http://sdn.sitecore.net/Reference/Sitecore%207/Developers%20Guide%20to%20Item%20Buck
ets%20and%20Search.aspx

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 161
Search
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
SearchanindexusingaLINQbasedsearchAPI.
Createacustomsearchresulttype.
Configurewhatgoesintoyourindexes,andhowtheyarestored.
Facetonasetofresults.
Content
SimpleSearch
DemoExecutingaSimpleSearch
1. Dropthesimplesearchcodefromtheprecedingslidesintoasublayoutcodebehindfile.
2. AttachabreakpointandnotethatanIEnumerable<T>isreturned.Thiscontainsallindexeditems.
3. Use.Where()tosearchforitem’swhosenamecontainsbike:
CodeSampleSitecoreProperty

.Where(x=>x.Name.Contains("bike"));

Inthefollowingdemo,wewill:
Buildasimplesearchandreturnallindexeditems.
Searchbytheitem’sNameproperty(Sitecoreproperty).
Searchbyitem’sHeading(developercreatedproperty).
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 162
4. Use.Where()tosearchfortheitemswhosemaincontentfieldcontainsbike:
CodeSampleDeveloperCreatedProperty
.Where(x=>x["main_content"].Contains("bike"));
5. Use.Where()tosearchforitemswhosecreatedateiswithinthedatespecified.(Notethat.Betweenisa
Sitecorespecificextension):
CodeSampleUsing‘Between’
.Where(x=>x.CreatedDate.Between(newDateTime(2013,06,03),DateTime.Now,Inclusion.Both));
BasicIndexConfiguration
Tip
UseSwitchOnRebuildLuceneIndexorSwitchOnRebuildSolrIndextoavoidanindexdirectorybeing
deletedwhileitisintheprocessofbeingrebuilt.
http://sdn.sitecore.net/upload/sitecore7/70/sitecore_search_and_indexing_guide_sc70a4.pdf
Tip
LuceneandSolraresearchplatforms.Theyarebuiltonthesametechnology,andtheoneyouchoose
dependsonyourrequirements.Luceneisbestusedforintegrated,locallymanagedsearch,whileSolr
offersascalable,enterpriselevelsolution.
Tip
Solrsupportsdistributedindexing,butLucenedoesnot.Thismeansthesearchindexescanbeoffloaded
toaseparateserverandthenaccessedbyallCDservers.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 163
WalkthroughIndexViewer
1. UsingtheSitecoreDesktop,clickStart>ControlPanel>Indexing>IndexingManage.
2. ClicktheRebuildbutton.

NoticethatthereisanadditionaloptionforSolr:bydefault,Sitecoredefinesthreeindexesoneper
database(Master,Core,andWeb).
3. Usingthefilesystem,navigatetothe/Data/indexesfolder.Youwillseeonefolderperindex.
4. Alternatively,youcanenabletoDevelopertabintheContentEditorandusetheRebuildIndexbutton
there:
Tip
ToviewrawLuceneindexes,useafreeopensourcetoolcalledLuke:http://code.google.com/p/luke.
LukecanalsobeusedonContentDeliverynetworkstoviewanindexhoweveritcantakeawritelockon
theindexes.Usethisforviewinginreadonlymode.Alsobecarefulifyouareopeningalargeindexona
deliveryenvironmentbecauseLukewillloaditallintomemory.LastlyLukecanopenindexescreatedby
differentversionsoftheLucenelibraryandeventheindexescreatedbySolr.
Inthefollowingwalkthrough,wewill:
UsetheIndexViewerontheSitecoreDesktoptorebuildtheindexes.
DefaultSitecore
indexes
Moreinformation
abouteachindex
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 164
LINQExamples
Tip
.Filter()and.Where()bothrestricttheresultlist(andcanbeusedincombination),but.Filterdoesnot
affectthescoring/rankingofthesearchhits.
CustomSearchResultType
Tip
Sitecoreprovidesastartingpointforasearchresultitemin:
Sitecore.ContentSearch.SearchTypes.SearchResultItem.Inheritinggivesyoupropertieslike:.Template,
.Language,.ID,andsoon.
The.PathspropertyonSearchResultItemletsyounarrowyoursearchbypathintheSitecoretree.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 165
Tip
Somestandardfieldsarealreadyindexedandstored(seeAdvancedConfiguration).Ifyouwanttoadda
standardfieldasapropertytoyourresultitem,usethepropertiesinSitecore.Search.BuiltinFieldswhen
definingtheIndexField.Thiswayyoucanavoidhavingtorememberstandardfieldnames.
Examplesofsupportedsearchresultpropertytypes
.NETbuiltinfloatingpointtypes
DateTime
String
GUID
SitecoreID
SitecoreShortID
DemoPaths,PaginationandSearchResultTypes
1. CreateacustomsearchtypecalledCustomSearchResult.Includeanumberofdifferentfieldsfromthe
Basetemplate,suchasPageHeading.
2. InheritfromSitecore’sbaseSearchResultItemclass.
3. FieldswithaspaceneedtheIndexFielddecoration,forexample:[IndexField("pageheading")].
4. Refactorsimplesearchtouseyournewcustomclass.Youwillnowbeabletoquerybypropertiesrather
thanstringfields.
5. Use.PathspropertyinheritedfromSearchResultItemtorestrictthesearchlocation.
6. Use.Page()topaginateresultset.
ReturningaResultSet
Inthefollowingdemo,wewill:
CreateacustomsearchtypecalledCustomSearchResult‐includeanumberofdifferent
fieldsfrombasetemplates.
InheritfromSitecore’sbaseSearchResultItemclass.
Refactorsearchtoquerypropertiesratherthanstrings.
Limitresultsetusing.Paths.
Paginateresults.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 166
TipAdvancedUseofFacets
Foramoreadvancedexampleofhowfacescanbeused,downloadtheAutohausdemofromtheSitecore
Marketplace:https://marketplace.sitecore.net/en/Modules/Autohaus.aspx
BestPractice
Whenyououtputalistofresults,youcaniteratethroughthelistofSearchHitobjectandusethevalues
inthe.Documenttoavoidhavingtohitthedatabaseforiteminformation.However,thiswillonlyworkif
yourfieldisstoredratherthanjustindexed.
Facets
Tip‐Security
HugeimprovementstosecurityarebeingmadeinlaterupdatestoSitecore7.Untilthen,refertoStack
Overflowforoptions:http://stackoverflow.com/questions/16683487/indexingsitecoreitemsecurityand
restrictingreturnedsearchresults.
DemoGetResults()andFacets
1. UsetheGetResults()methodtoreturnaresultsobjectratherthananIEnumerable.
2. Returnfacetcategories,alistoftotalsearchresults(regardlessofpagination,thissavesyoufrom
havingtodomultiplequeries),andacollectionofhits.
Inthefollowingdemo,wewill:
ReturntheSearchResultsobject.
Setcount,hits,andfacetstovariablesandinspect.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 167
IndexConfiguration
WhichFieldsShouldBeIndexed?
Important
Itisessentialthatyoufinetuneyourindextoincludeonlythefieldsthatyourequire.Manyunnecessary
standardfieldsareexcludedbydefault.Asyoursolutionscales,anindexthathasnotbeentunedwill
becomedifficulttomanageandtakealongtimetogenerate.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 168
HowShouldFieldsBeIndexed?
Tip
TheDefaultIndexConfiguration.configcontainscommentsthatexplainwhateachattributedoesand
whattheoptionsare(forexample,indexType,vectorType).
Tip
Youcanindexmediaitems(andtheircontentsinthecaseofPDFs)aswellseeblogpostformore
information:
http://www.sitecore.net/Community/TechnicalBlogs/JohnWestSitecoreBlog/Posts/2013/04/Sitecore7
IndexingMediawithIFilters.aspx
StoreorIndex?
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 169
ComputedFields
Tip
YoucanalsouseVirtualFieldsthatevaluateonrequest.Theyareusefulifyouneedtoperforma
calculationontheflyratherthanretrieveastoredvalue.
Tip
Sitecoreshipswithatoolthatallowsyoutotestthescalabilityofyoursearchprovidersandthewayyour
indexeshavebeensetup.Formoreinformation,seeTheDeveloper’sGuidetoItemBucketsandSearch
(previoustopicsExtend).
ApplyTopic8.270min
RefactorNewsListing
OutputNewsArticlesUsingSitecoreSearchAPI
1. InVisualStudio,openthebasecorenewslisting.ascx.csfile(under
/layouts/BaseCore/content/basecorenewslisting.ascx.cs).
2. InordertotakeadvantageofthesearchAPI,makesureyouincludethefollowingnamespaces:
CodeSampleSitecoreProperty

usingSitecore.ContentSearch;
usingSitecore.ContentSearch.SearchTypes;
usingSitecore.ContentSearch.Linq;
3. UsingVisualStudio,createanewclasscalled
NewsResult
.Eithercreateitin/layouts/BaseCoreorina
newfolderunderBaseCoreintheTraining.Utilitiesproject;thisisyourcustomsearchresultclass.
4. Inheritfromthe
Sitecore.ContentSearch.SearchTypes.SearchResultItem
baseclass.
Currently,weareoutputtingalistofnewsarticlesusingthe
.GetDescendants()
method.Inthefollowing
labs,youwill:
RefactorthenewslistingcodetoretrievedatafromanindexusingthesearchAPI.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 170
5. Addthepropertiesspecifiedinthefollowingtable:
Propertyname
Propertydecoration
PageHeading
[IndexField("pageheading")]
PageSummary
[IndexField("pagesummary")]
6. Usethecodeexamplebelowasaguide:
CodeSampleSearchClassProperty
[IndexField("metadescription")]
publicstringMetaDescription{get;set;}
Tip
Ifyouwanttoincludeasystemfieldinyourcustomsearchresultclass,considerusingtheBuiltinFields
namespacetodecoratethepropertiesratherthantypingthefieldnameoutasastring:
[IndexField(BuiltinFields.Version)]
stringVersion{get;set;}
7. UsingVisualStudio,openthenewslistingsublayoutcodebehindfile(.cs).
Previously,newsarticleswereretrievedusing.GetDescendants().Inthisrefactor,wewanttoproduce
exactlythesameresultbyqueryinganindex.Apartiallycompletedcodesamplehasbeenprovidedin
thestudentresourcefolder(WNDLabs>Module8>Topic8.2>LabA>basecorenewslisting.ascx.cs).
Werecommendthatyoureferbacktothematerialsonhowtoconstructaquery.
8. Retrievethewebindexeitherbyretrievingitbyname(sitecore_web_index),orbyusinga
SitecoreIndexableItem.(ThisobjectisconstructedbypassingaSitecoreiteminasaparameter).Seethe
codeexamplebelow.Forease,retrievetheindexbyname.
CodeSampleIndexbyName
Sitecore.ContentSearch.ContentSearchManager.GetIndex("sitecore_web_index");
CodeSampleSitecoreIndexableItem
SitecoreIndexableItemindexableItem=newSitecoreIndexableItem(item);
varindex=Sitecore.ContentSearch.ContentSearchManager.GetIndex(item);
9. Createasearchcontextfromthatindex.
10. UsetheGetQueryable()methodonthesearchcontextobjecttoretrieveanIQueryable.
11. UseLINQstatementstoreturnonlyitemsthataredescendantsofthecurrentnewslistingandare
basedontheNewsArticletemplate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 171
SitecoreAPI.Paths

Tolimitthesectionofthecontenttreethatresultsarereturnedfrom,usethePathspropertyonthe
baseclass;thiswillreturnonlyitemsthathaveaparticularIDintheirlistofancestors(forexample,
HomewouldhavetheIDfortheContentandsitecoreitems):
x.Paths.Contains(item.ID)
12. OrderbytheCreatedDateproperty(foundontheSitecoreSearchResultbaseclass).
13. AttheendoftheLINQstatement,usetheGetResults()methodtoreturnaSearchResultsobject.This
shouldcomeafterany.Where()and.OrderBy().Thefollowingexampleshowsaquerywithasingle
.Where()using.GetResults():
CodeSampleSearchClassProperty
varquery=context.GetQueryable<SearchResultItem>()
.Where(x=>x.Name=="Bikes")
.GetResults();
14. TheSearchResultsobjecthasapropertycalled.Hits.ItisacollectionofSearchHitobjects,eachofwhich
hasa.Documentproperty.The.DocumentpropertyisaNewsResultobject.
15. SelectoutalistofNewsResultobjects:
CodeSampleSearchClassProperty
.GetResults();results.Hits.Select(x=>x.Document)
16. Bindresultstoarepeater,deletetheexistingrepeaterandusethesampleprovidedinthestudent
resourcefolder(WNDLabs>Module8>Topic8.2>LabB>basecorenewslisting.ascx).
17. MakesureyouchangetheItemTypeattributeontherepeatertoyourcustomresultsclass.
18. Usetheformatinthefiletooutputpropertiesofyourobjects.Noticethecolonafterthe#symbol.All
datashouldcomefromtheindex;youshouldnotneedtoretrievetheitemfromSitecoreincluding
the.URLproperty.
Important
AsofUpdate2,the.URLpropertyrequiressomemodification.Askyourinstructorformoreinformation.
KnowledgeCheck
Atthispoint,allpropertiesthatareretrievingnotstandardfieldswillbeblank.Whyisthis?Hint:think
aboutthestoragetypeconfiguration.
19. IntheVisualStudiosolution,open/App_Config/Include/Basecore/Basecore.Search.config.
20. Intheraw:AddFieldByFieldNamesection,ensurethatPageHeading,andPageSummaryarelisted.
21. MakesurethestorageTypeattributeissettoYES.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 172
22. IntheContentEditor,usetheDevelopertabtorebuildthewebindex.(Ifyouhaveanyunpublished
newsarticles,makesureyoupublishtheseitemsfirst.Otherwise,theywillnotbeaddedtotheweb
index).
23. Saveanddeploythesolution.
24. NavigatetotheNewsListingpageonthesiteandconfirmthatnewsarticlesarebeingoutputindate
order.
Tip
Ifyouareseeingmorethanoneversionofanitem,itmightbebecauseyouhavemorethanonelanguage
versionofeachspecified.Narrowitdownbyaddinga.Where()toyourquerythatonlyreturnsitemsfrom
thecontextlanguage(ordinarilyfoundintheRegionalISOCodefieldonthelanguagedefinitionitem,but
forthepurposesofthisexerciseyoucanusetheitemnametosavetime).
Extend
SitecoreSearchandIndexingGuide
http://sdn.sitecore.net/Reference/Sitecore%207/Sitecore%20Search%20and%20Indexing%20G
uide.aspx
SearchScalingGuide
http://sdn.sitecore.net/Reference/Sitecore%207/Sitecore%20Search%20and%20CMS%20Scali
ng%20Guide.aspx
Sitecore7DevelopmentTeamBlog
http://www.sitecore.net/Community/TechnicalBlogs/Sitecore7DevelopmentTeam.aspx
Sitecore7Hangouts
http://www.youtube.com/user/SitecorePM
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 173
RecommendedPractices
Contents:
WorkingwithMedia
CachingandPerformance
Publishing
InstallingandScalingSitecore
TeamDevelopmentandtheDevelopmentEnvironment
HowtoDealwithDeployment
BasicSecurity
Workflow

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 174
WorkingwithMedia
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Understandhowmediagetsstored.
DefinewhatsettingscanbechangedintheWeb.Configrelatingtomediaitems.
Describehowtochangemediaextensionsfrom.ashxtothetruefileending.
Content
StoringMedia
Tip
Thereisafileuploadfolderoninthewebsitefolder.Ifyouenablethisfolderintheweb.config,itwill
monitormediaitemsdroppedthere.Iffilesdogetadded,thentheyappearinthemedialibrary.Keepin
mindwhenyoudeployyoursolutionthatifyouarestoringmediafilesonthefilesystem,theyneedtobe
replicatedtoyournewenvironment.Werecommendthatyoustoremediainthedatabaseforthat
reason.However,itisusefulforstoringlargefiles(videolibrary)ondiskbecausethatwayyoudon’tbloat
thedatabaseandthemediadatabasefiles(MDF)remainlean.Storingmediainthedatabasesometimes
canbeinefficientand,dependingonthesize,mightactuallyhurtperformance.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 175
Mapping
FileExtensions
WalkthroughChangingFileExtensions
1. GotoTraincore.
2. Inspecttheelementforanimage‐.ashx
3. ChangetheMedia.RequestExtensionvalueintheweb.config.
4. Inspecttheelementagain.Thetrueextensionisrevealed.
Inthefollowing
walkthrough,wewill:
Chan
g
ethefileextensioninconfi
g
uration.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 176
CachingandPerformance
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Listtheitemcachelayers.
NameanactionthatclearsHTMLcache.
Discussprefetchcache.
Discusswhereyoucanclearallcaches.
Statewherecachesettingsaredefined.
Describevariouscachingoptions.
ExplainthepurposeofProfileandDebugmodeinthePageEditor.
Content
ItemCache
HTMLCache
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 177
Tip
HTMLcachingisdefinedonindividualcomponents.Thisisanotherreasontomakesureyou
componentizeyourpage.
Cachingbyparameters/user/datameansthataversionofyourcomponentcanbecachedunlessthose
parameterschange.YoumightwanttocacheacomponentforallusersintheUS,butcacheisdifferent
HTMLforUKusers.Alternatively,ifyourcomponentacceptsvariousdatasources,youcancachethat
componentwithitsdifferentdatasource,whichisthenaddedtotheindexofthecache.Thenwhenthe
componentisrequestedagain,itispulledfromthecachewithitsrelevantdatasource.
ClearingCache
Important
Ifyouhaveaseparatesiteintheweb.config,makesurethenameofthesiteislistedasasiteinthe
HtmlCacheClearereventhandlerintheweb.config:
WalkthroughClearingCache
SetupHTMLcacheforacomponent
1. Navigatetohttp://traincore/sitecore/admin/cache.aspx.
2. Noticethatmaximumcachesizesarelistedinthecolumnontherightsideofthewindow.
3. DemonstratethatcachescanbeclearedusingtheClearallbutton.
Inthefollowingwalkthrough,wewill:
Navigatetohttp://traincore/sitecore/admin/cache.aspx.
Noticemaximumcachesizesarelistedintherighthandcolumn.
DemonstratethatcachescanbeclearedusingtheClearAllbutton.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 178
CacheTuningandConfiguration
Tip
Seecachereferenceguideformoreinformation:
http://sdn.sitecore.net/Reference/Sitecore%206/Cache%20Configuration%20Reference.aspx
Tip
SitecoreRockscachesinterfaceusingSitecoreRocks,rightclickonaninstanceandinCommandy,
typecache.Yougetahandyinterfaceforviewingandconfiguringdifferentcachesettings.Foramini
tutorialsee:http://www.sitecore.net/Community/TechnicalBlogs/TrevorCampbell/Posts/2013/02/28
DaysofSitecoreRocksManagePart3.aspx
DemoVariousCacheSettings
1. Lookatthevariouscachesettingsintheweb.config:
Defaultsettings
Cachesizesspecifiedinthe<databases>section
Cachesizesspecifiedonthe<site>nodesorbelowthe<sites>section
2. Lookatvariouscacheconfigurationfilesin/App_Config/Prefetch.
3. Lookatthestatisticspage.
Inthefollowingdemo,wewill:
Lookatthevariouscachesettingsavailableintheweb.config.
Lookatvariouscacheinterfaces.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 179
ProfilingandDebugging
Tip
ExperienceCMSPerformanceTuningGuide:
http://sdn.sitecore.net/Reference/Sitecore%207/CMS%20Performance%20Tuning%20Guide.aspx
ExperienceCMSDiagnosticsGuide:
http://sdn.sitecore.net/Reference/Sitecore%207/CMS%20Diagnostics%20Guide.aspx
WalkthroughUseProfilerandDebugger
1. LogintotheSitecoreDesktopandstartthesiteindebugmodebyclickingSitecore>Debug.
Notethattheribbonatthetopofthepageallowsyoutoenable/disableprofilingandtracing:

Inthefollowingwalkthrough,wewill:
Lookatdebugmode.
Enableanddisableprofilingandtracing.
Lookattheprofiletableandtrace.
Visit/sitecore/admin/stats.aspx.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 180
2. Debugmodeallowsyoutoseetheprofile,cachesettingsandoutputofindividualcomponents(Yet
anotherreasontosplityourpageintocomponentsthatcanbeeasilyisolatedandprofiled):
3. Theinformationaboutindividualcomponentsissummarizedintheprofiletableatthebottomofthe
page.
4. Thebottomofthepagealsoshowsyouthetrace.Noticethatthestepsthatareexecutedaretheones
definedinthehttpRequestPipeline(resolvesite,resolvelanguage,resolvedevice,andsoon).
5. Aggregatedstatisticsaboutcomponentloadtimesarealsoavailableonthe/sitecore/admin/stats.aspx
page.Totaltimerepresentsthetotaltimeithastakentoloadthecontrolacrossallinvocations.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 181
Publishing
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describethedifferentpublishingmodes.
Namethreeelementsthatpublishingrestrictionsapplyto.
Discussrecommendedpracticesforpublishingstrategies.
Content
TypesofPublishing
PublishingRestrictions
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 182
PublishingStrategies
DemoPublishingOptionsandRestrictions
1. IntheContentEditor,selectacontentitemsuchastermsandconditionsunder:/sitecore/sitecore
cyclingholidays/Home.
2. Ontheribbon,selectPublishtab>Changerestrictions:
3. LookatthethreetabsVersion,Item,andTarget:
IfyouclearthePublishablecheckboxontheVersionsorItemtab,thatitemorversionwillberemoved
whentheitemisnextpublished.
IfyousetaPublishableFromandPublishableTodateandtime,theitemorversionwillbepublishable
betweenthosedatesandtimesonly.
Inthefollowingwalkthrough,wewill:
SetuppublishingrestrictionsusingSitecoreRocks.
SetuppublishingrestrictionsusingtheContentEditor.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 183
4. GobacktotheContentEditor.OnthePublishtab,clickPublishingViewer.Thisdialogshowsagraph
ofwhenaparticularversionwasavailableonthelivesite:
5. SwitchtoSitecoreRocks.RightclicktheitemthatyouworkedonintheContentEditor,andselect
Tasks>SetPublishingRestrictions.AsimilarinterfacetotheonedisplayedintheContentEditorwill
appear:
SitecoreRocksandPublishing
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 184
Tip
SeetheContentAPICookbookforinformationonhowtopublishanitemusingtheAPI:
http://sdn.sitecore.net/upload/sitecore6/64/content_api_cookbook_sc64_and_latera4.pdf
Extend
PublishingimprovementsinSitecore7.2
https://www.sitecore.net/Learn/Blogs/Technical
Blogs/Reinnovations/Posts/2014/03/PublishingImprovementsin72.aspx
PublishingthroughSitecoreRocks
http://www.sitecore.net/unitedkingdom/Community/TechnicalBlogs/Trevor
Campbell/Posts/2013/02/28DaysofSitecoreRocksPublishing.aspx

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 185
InstallingandScalingSitecore
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Discusstheinstaller’sfunctionality.
NametwotoolsthatcanbeusedtoinstallSitecoreusingscripts.
Describethethreesystemcomponentsthatgetinstalled.
Namethreefoldersthatgetinstalled.
Discusswhatthesefolderscontain.
Drawouttheproduction/liveenvironmentasrecommendedbySitecore.
Nameaguidetohelpwithscalingasolution.
Content
InstallerorManual.ZIPFiles
Tip
Usingtheinstaller,youcaninstallthedatabasesonlyontheDBserver.Theclientinstallationmustbe
performedseparately,soyouwillruntheinstallertwice.
Important
Whenyouhaveusedthe.exeforinstallation,youshoulduseadd/removeprogramstouninstallit.Ifyou
justdeletethefilesanddatabasesandsoon,youwillleaveentriesinyourregistry.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 186
Scripts(SIMorSitecoreRocks)
SIMdownloadanddocumentation:
http://marketplace.sitecore.net/en/Modules/Sitecore_Instance_Manager.aspx
SitecoreRocks:
http://marketplace.sitecore.net/Modules/Sitecore_Rocks.aspx
Sitecore’sIncludeFolder
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 187
ScalingInfrastructure
ComplexScalingScenarios
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 188
MoreComplexScalingScenarios
Important
Requirementsdepend100%onthesizeofyoursolution,theexpectedtrafficandonwhetherornotyou
areusingpersonalizationandanalyticsfeatures.
InstallationGuides
http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/Installation.aspx
Troubleshooting
http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/Installation%20Troubleshootin
g.aspx
Scalingguide
http://sdn.sitecore.net/Reference/Sitecore%206/Scaling%20Guide.aspx

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 189
TeamDevelopmentandtheDevelopmentEnvironment
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Listthetwodevelopmentenvironmentsandtheiruses.
Describehowtosyncyourfilesandcontentacrossenvironments.
Namethreetoolsusedforserialization.
Describepackages.
NametheASPXusedtoforupgradingSitecore.
Content
SettingUpaSolution
Development
model
Benefits
Drawbacks
Inside
theweb
root:
Solutionsetupisquickand
straightforward
Ifyourteamisusingthecode
besidedevelopmentmodel,you
willbeabletoseeyourchanges
almostimmediately
Noclearseparationofownership
Difficulttotransformconfigurationfiles
Developmentsitesmaycontaincode
besidefilesorotherunnecessaryartifacts
thatmayaltersitebehaviorinadvertently
Outside
the
webroot:
Clearseparationbetweenthe
solutionfilesandSitecoreowned
files
Abilitytotransformconfiguration
fileswithinlocaldeveloper
environmentswithoutchanging
thedefaultconfigfiles
Bettersuitedformultisite
solutions
Solutionscanbebundledeasily
forshipment
Developmentsitesremainclearof
codebehindfiles
Changestocodetypicallyneedtobe
compiledandcopiedtothewebrootin
ordertoseethechangesanddebug,
whichcanalsotriggeryourapplicationto
recycle
Initialsolutionsetupcanbecomplexas
youcreateandemploycustompostbuild
actions

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 190
SourceControlandSerializationOptions
Important
Serializationmaynotbeappropriatewhendeployingchangestoastagingorproductionenvironment
becauseitoverwritesitems.
WalkthroughSerializingItems
1. Navigatetotheserializationpagehttp://traincore/sitecore/admin/serialization.aspxandserializeoneof
thedatabasesinitsentirety.
2. Navigatetothe/Data/serializationfolderandnotethatafolderwithserializeditemshasbeencreated
asaresult.
3. LogintotheContentEditoranddemonstratethatdatabases,individualitems,oritemtreescanbe
serializedfromtheDevelopertab:
4. UsingSitecoreRocks,demonstratethatitemscanbeserializedbyrightclickingandselectingTools>
Serialization:

Inthefollowingwalkthrough,wewill:
Serializetheentiredatabaseusinghttp://traincore/sitecore/admin/serialization.aspx.
SerializeitemsusingtheDevelopertabintheContentEditor.
SerializeitemsusingSitecoreRocks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 191
Important
Serializingthedatabasewillnotserializeusersandroles.However,youcanserializethemfromtheRole
ManagerandUserManagerinterfacesontheSitecoreDesktop.
Tip
Youcanchangethefolderthatitemsareserializedtobychangingthefollowingsettingintheweb.config:
<settingname="SerializationFolder"value="$(dataFolder)/serialization"/>
Serializationguide:
http://sdn.sitecore.net/Reference/Sitecore%207/Serialization%20Guide.aspx
TeamDevelopmentforSitecore:
http://www.hhogdev.com/Products/TeamDevelopmentforSitecore/Overview.aspx
Packages
Tip
SeethePackageDesignerAdministrationGuideifyouareusingthePackageDesignerinterfaceonthe
SitecoreDesktop:
http://sdn.sitecore.net/Reference/Sitecore%207/Package%20Designer%20Administrator%20Guide.aspx
Important
Whenyoupackagesecurityaccounts,allpasswordsarelostandhavetobereset.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 192
UpdatePackages
DemoCreateaPackageUsingSitecoreDesktop
1. LogintotheSitecoreDesktopandclickSitecore>DevelopmentTools>PackageDesigner.
2. Itemscanbeaddedstaticallyordynamicallyusingaquery(forexample,allitemscreatedinthepastfour
days).
3. YoucanpreviewpackagecontentsusingPreview>Lookup.
4. Generatea.zipfiletocreateafileinthefilesystem.
Tip
Youcanchangethefolderthatpackagesarebuilttobychangingthefollowingsettingintheweb.config:
<settingname="PackagePath"value="$(dataFolder)/packages"/>
WalkthroughCreateaPackageUsingSitecoreRocks
1. InSolutionExplorer,rightclicktheTrainingsolutionandselecttheAdd>NewItemoption.
2. SelectSitecorefromtheVisualC#menuontheleftsideofthescreen.ThenselecttheSitecore
Packageoption,andgiveitaname.
3. ConnectittotheTraincoreinstancewhenprompted.
4. ClickontheItemtabthendraganddropitemsfromthetreeintothepackage.
5. Draganddropfilesfromthe/WebsitefolderinSitecoreRocksintothepackageandnoticethattheyare
addedintotheFiletab.
Note:youcannotdraganddropfilesfromyoursolution,becausesolutionfilesareindependentofthe
Sitecoreinstance.
Inthefollowingwalkthrough,wewill:
CreateapackageusingthePackageDesignerintheSitecoreDesktop.
Inthefollowingwalkthrough,wewill:
CreateapackageusingSitecoreRocks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 193
6. Noticethatrightclickingonanitemgivesyouoptionstoadd,remove,andupdateitschildren:
7. Youalsohavetheoptiontoadddependencies.Forexample,ifyouaddanitem,youmaywanttoaddits
template,associatedrenderings,andpotentiallyanyotheritemsitreferences.
8. BuildapackageandopenWindowsExplorerwhenprompted.Noticethata.zipfilehasbeencreatedin
thesamelocationasyoursolution.HoweverSitecorestorespackagesintheDatafolderoftheSitecore
installation.
9. Toinstallapackage,rightclicktheSitecoreinstanceinSitecoreRocksandselectManagePackages…
10. ClickUploadandInstalltouploadapackagetotheinstance:
11. Whenthepackageappears,clickInstall.YouaregiventheoptiontoAnalyzeandCreateAntiPackage
beforeinstalling:
Antipackagesallowyoutoremovethefilesanditemsthatwereinstalled,andrestorethefilesand
itemsthatwerechanged.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 194
ApplyTopic9.55min
InstallaPackage
InstallaPackageUsingSitecoreRocks
1. Toinstallapackage,rightclicktheSitecoreinstanceandclicktheManagePackages…option.
2. Onlypackagesinyourpackagerepositorywillbevisible.EitherusetheRepositoriesbuttontoadda
repositorywithapackagefile,orcopythepackagefileintotheexistingrepository(theDatafolder,in
yourSitecoreinstallation).
3. Noticethatyoucangenerateanantipackagethatfunctionsasanuninstaller.
Extend
SitecoreNuGetPackages
http://vsplugins.sitecore.net/SitecoreNuGet.ashx

Using
SitecoreRocks,installthepackageyoujustcreatedinthewalkthrough.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 195
HowtoDealwithDeployment
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Statethedifferencebetweenpublishinganddeployment.
Listsomepointstorememberwhendeployingtoanauthoringenvironment.
Discussoptionsforreversecontentpromotion.
Content
DifferenceBetweenPublishingandDeployment
 
DeploymentBetweenEnvironments
 
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 196
PointstoRemember
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 197
BasicSecurity
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Nametheapplicationfordefiningaccessrights.
Nametheapplicationforviewingtheresolvedaccessrights.
Listtwoentitiesthataccessrightscanbeassignedto.
Describethethreepermissionsthatareappliedtoaccessrights.
Discusshowtooverrideaccessrights.
Content
SecurityEditorandAccessViewer
 
Tip
Formoreinformationaboutsettinguprolesandaccessrights,pleaserefertotheSecurity
Administrator’sCookbook:
http://sdn.sitecore.net/upload/sitecore7/70/security_administrators_cookbook_sc70a4.pdf
YoucanalsoattendSitecore’stheSecurityAdministratorcourse:http://www.sitecore.net/servicesand
support/training/administratortraining/ssasitecorecmssecurityadministrator.aspx
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 198
Roles
 
RecommendedPractices
Definearolepertask(forexample,newseditororimagelibrarymanager)andavoiddefiningaccess
rightsdirectlyonusers.Thatway,itiseasiertomaintainateamofeditorsastheirjobresponsibilities
change.
Extend
Securityreference
http://sdn.sitecore.net/Reference/Sitecore%206/Security%20Reference.aspx
SecurityAPICookbook
http://sdn.sitecore.net/Reference/Sitecore%206/Security%20API%20Cookbook.aspx
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 199
Workflow
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describethepurposeofaworkflow.
Discusswhataworkflowconsistsof.
Statewhenanitemispublishable.
Statethreeworkflowrecommendations.
Content
BusinessUseCase
Itmaybeillegaltohavecertaincontentonlineatcertainpointsintimeforcingauthorstocreatenew
versionsofthecontent.Orwithsomesensitivematerial,authorsmayhavetohavedifferentgroups
intheorganizationapprovethematerialbeforeitcangolive.Workflowsallowyoutosetonesource
ofresponsibilityfortheseissues.
DemoUsingaWorkflowasanAuthor
1. UsingtheContentEditor,rightclickonthe/sitecore/content/sitecorecyclingholidays/Home/holidays
itemandinsertaNewHoliday.NameitAllaroundtheworld.
2. Noticethatamessageappearsatthetopofthecontentpane:
3. ClickthearrowundertheEditbuttonontheribbon,andselectSubmit:
4. Enteracommentwhenprompted.

Inthefollowingdemo,wewill:
Pushanitemthroughworkflow.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 200
5. Thisisatwostepworkflow.RightclickonthearrowundertheEditbuttonasecondtime,andselect
Approve.Writeacommentwhenprompted.Thisitemwillnowgointoafinalworkflowstate,andis
thenpublishable.Inthisparticularcase,enteringintothefinalworkflowstatestriggersanautomatic
publishoftheitem.
Tip
YoucanalsousetheWorkboxinterfacetomanagebulkmanageitemsinworkflow.Thisinterfaceis
availableontheSitecoreDesktop,orasabuttonatthebottomoftheContentEditor.Youcanalsouse
theReviewtabintheContentEditor:
BestPractices
Workflowisusefulfortworeasonsinparticular;itmaintainsahistoryofchanges,allowingauthorsto
rollbacktoapreviousversion,anditpreventsaccidentalpublishingofcontent.Onlycontentinafinal
statewillappearonthelivesite.Werecommendthatyou:
SpecifyworkflowsontheStandardValuesofatemplate.
Useworkflowsfromthebeginningforallthecontent.
Usecleanupscriptstoremoveunnecessary,oldernumbered
versions.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 201
WhatIsaWorkflow?
 
Workflow
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 202
MarketingFunctionality
Contents:
IntroductiontotheCustomerExperiencePlatform(XP)
EngagementValueandGoals
ProfilingandPersonalization

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 203
IntroductiontotheCustomerExperiencePlatform(XP)
Introduction
Bytheendofthistopicyourwillbeableto:
StatethethreemainfeaturesoftheCustomerExperiencePlatform.
Listtwotypesofreports.
DescribewhycomponentizationandtheuseofdatasourcesareintegraltousingtheXP.
DiscusswhybuildingfortheXPismucheasierthanretrofittingfeatureslateron.
Content
MarketingFunctionality
BuildingfortheXP
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 204
I’mNotUsingItyet
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 205
EngagementValueandGoals
Introduction
Bytheendofthetopicyouwillbeableto:
Describethedifferencebetweenvalueandtraffic.
Creategoalsandassignthem.
ViewtheDashboardandEngagementAnalyticsreports.
Setupandrunmultivariatetests.
Content
Valuevs.Traffic
Goals
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 206
BestPractice
Decidingwhatyourgoalsareandhowmuchtheyareworthiscrucialtothecollectionofmeaningful
data.CustomersarestronglyencouragedtoattendtheXPScopingWorkshop:
http://www.sitecore.net/unitedkingdom/Support/ConsultingServices/BusinessOptimization
Services/CEPScopingWorkshop.aspx.
DemoCreateandAssignaGoal
1. UsingtheMarketingCenter,createagoalcalledBookaholiday.
2. Giveitavalueof50.TheentireSitecoreCyclingHolidayssiteisgearedtowardsellingcyclingholidays,
sothisisthemostimportanttaskanauthorcanperform.
3. OntheReviewtab,deploythegoal,(itisautomaticallypartofanapprovalprocessandneedstobe
published.Youwilllearnmoreaboutthisinmodule10).
4. IntheContentEditor,locatethebookingthankyoupageandassignthegoalusingtheGoals
commandontheAnalyzetab.
5. Openanotherbrowser,forexample,InternetExplorer,andbookaholiday.
6. Youwillberedirectedtothethankyoupageafterasuccessfulbooking.
Reporting

Inthefollowingdemo,wewill:
UsingtheMarketingCenter,createagoalcalledBookaholiday.
Giveitavalueof50.
IntheContentEditor,locatethebookingpageandassignthegoalusingtheGoalsbutton
ontheAnalyzetab.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 207
DemoExecutiveInsightDashboardandEngagementAnalytics
1. OpentheExecutiveInsightDashboardandselecttheVisitscheckboxontherightsideofthescreen.
Theresultinggraphshowstheaveragevaluepervisitforthetimeperiodspecified.
2. Notethatyoucanviewbyyear,month,weekorday.
3. NotetheotheroverviewstatisticsthattheDashboardprovides:averagevaluepervisitbyentrypage,
searchkeyword,sourceandreferringsite.
4. Bycontrast,EngagementAnalyticsreportsaremuchmoregranular.ExpandtheReportsitem.Clickthe
Sales>TopLeadsbyValue>Unclassifiedorganizationsoptions.(Makesurethatyouhaveselecteda
widedaterange).
5. Notethatyoucanapplyfilters,subscribetoaparticularlead,orviewmoredetailsaboutthatlead,
includingdrillingdowntoindividualvisits.
6. Locatethesessionwhereyoucompletedtheholidaybookinggoal.Notethatthevisithasan
engagementvalueassociatedwithit.
7. EngagementAnalyticsreportsalsoprovidesstatisticsonparticulareventsrelatedtositehealth(for
example,commonmistakesandnotfoundURLs).
Tip
TheDashboardcollectsdataovertimeandonlydisplaysdatawhenthenumberofvisitsrecordedexceeds
theMimimumVisitsFilter(setto50bydefault)thatwassetin:
\sitecore\shell\Applications\Reports\Dashboard\Configuration.config
Testing

Inthefollowingdemo,wewill:
ViewtheExecutiveInsightDashboard.
ViewtheEngagementAnalyticsreports.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 208
Tip
Youneedtothinkabouttestingbeforeyoustartbuilding.Giventhatyoucanchangethedatasourceor
component,thinkaboutthefollowingexamples:
Ifyouwanttovarycolorordesign,changethecomponent.OntheSitecoreCyclingHolidays
website,coloranddesignis,inpart,determinedbyparameters.Thismeansweneedtosetup
aseparatetestingcomponentifwewanttotestdesign.
Ifyouwanttovarycontentthatisnotpartofthemaincontentofacomponentsuchasbutton
textorformlabels,thesevaluesneedtobedefinedonyourdatasource.Forexample,you
mighthavea‘form’componentthatacceptsa‘form’itemontheSitecoreCyclingHolidays
website.OurformsusevaluesfromtheDomainDictionary,sowewouldneedtosetupa
separatetestingcomponent.
Ifyouexpecttobedoingalotofmultivariatetesting,makesureyoucomponentizeyourpage
andkeepalltestablevaluesinadatasource.Thefunctionalityreliesentirelyonbeingableto
changecomponentsanddatasources.
DemoSettingUpaMultivariateTest
1. OpenthehomepageinEditmodeandmakesuretheDesigningcheckboxisselectedontheViewtab.
2. Selectthecomponentyouwishtotest.ClicktheTestthecomponentbuttononthecontextmenu.
3. Addanewvariation(Itwilldefaulttowhatisalreadyselected).Thenaddasecondvariationandonly
changethedatasourceofthecomponent.

Inthefollowingdemo,wewill:
SetupamultivariatetestonaGeneralWidgetcomponent.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 209
4. Noticethatyoucanscrollbetweenthevariations.
5. SmartpublishthepageandstartthetestbynavigatingtotheTestingtabandclickingtheStartTest
button.Anitemwillbecreatedinthetreeatthispoint.Thereareextendedpropertiesonthisitem(such
as,whethertomakethevariationstickyorrandom).
6. Lookatthehomepageindifferentbrowsers,usingdifferentsessionstoemulatedifferentvisits(for
example,inInternetExplorer,selectFile>NewSession).Notethatyounowreceiveavariationofthe
componentatrandom.
7. Inoneofthesessions,completethegoalthatwassetupearlierinthemodule.
8. Gobackintoeditingmodeandlookattheresultsofthetest.Youmayhavetorecycletheapplication
pooltoseethevalue.
9. Stopthetestandyouwillbegiventheoptiontopickthewinningcomponent.
Important
Testresultsareonlyusedtodeterminewhichcomponenttoselect.Theyarenotsaved.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 210
ApplyTopic10.2
CreatingandAssigningGoals
CreateandAssignaContactPageGoal
1. UsingtheSitecoreDesktop,opentheMarketingCenter.
2. CreateanewgoalcalledViewedcontactpageandassignitamaxvalueof5.
3. OntheReviewtab,deploythegoal.
4. UsingtheContentEditor,assignthegoaltothecontactpagebyselectingtheitem,clickingtheGoals
optionontheAnalyzetab,andthenselectingthatgoalyoucreated.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 211
ProfilingandPersonalization
Introduction
Bytheendofthistopicyouwillbeableto
Setupprofiledimensionsandkeys.
Describehowaprofilecardaggregatesprofilekeyswithinadimension.
Assignprofilecardstoitems.
Setupacustomprofilecard.
Statethedifferencebetweenaprofilecardandapatterncard.
Content
Personalization
BestPractice
Encourageauthorstomakecontentprofilingaroutinetaskorriskendingupwith40,000itemsthat
requireprofiling.Makesurethatameaningfulprofiletaxonomyhasbeencreated.Definingdimensions,
keys,profilecardsandpatterncardsisabusinessdecisionnotadevelopmentdecision.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 212
DemoPersonalizeBasedonPageVisited
1. UsingthePageEditor,selectoneoftheGeneralWidgetcomponentsonthehomepage.
2. ClickthePersonalizationbutton.
3. AddanewconditionnameitExperts.
4. CreatearulethatsayswhenBattleoftheHillshasbeenvisited:

5. InthePersonalizeContentdropdownmenu,select:/sitecore/content/sitecorecycling
holidays/global/reusablecontent/forexperts.
6. Republishthepage,andlogoutofthePageEditor.
7. Openanewbrowser,suchasInternetExplorer.Ensurethatthebrowsercacheiscleared.
8. Browsetohttp://traincore/.NotewhichGeneralWidgetcomponentsarebeingdisplayed.
9. VisittheBattleoftheHillsholidaypage,andthengobacktoHome.Thecomponentshouldnowbe
displayingtheforexpertscontent.
ProfilingContentItems

Inthefollowingdemo,wewill:
SetupapersonalizationrulethatchangesahomepageGeneralWidgetcomponent
datasourcetoExpertHolidaysiftheBattleoftheHillssitehasbeenvisited.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 213
DemoProfileContent
1. OpentheContentEditor.
2. SelecttheBattleoftheHillsholidayitemunder:/sitecore/content/sitecorecycling
holidays/Home/holidays.
3. ClicktheAnalyticsiconinthetoprighthandcornerofthecontentpane:
4. ClickEditnexttotheHolidaysprofiledimension.
5. SelecttheTouristprofilecard.Thisbulkassignscertainprofilepoints,whichyoucanseeintheright
handgraph:
6. ClickOK,andthenclickEditnexttotheBikesprofiledimension.
7. ClicktheCustomizebuttoninthetoprighthandcorner.
8. SetMountainBiketo10.
9. ClickOK,andthenclickClose.

Inthefollowingdemo,wewill:
AssignTouristprofilecardtoaholidayintheHolidaysprofilingdimension.
AssigncustompointvaluesintheBike’sprofilingdimension.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 214
OptionalTopics
Contents:
BranchTemplates
OtherItemandTemplateProperties
PipelinesandEvents
Rules
PlaceholderOverrides

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 215
BranchTemplates
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Describehowtocreatealistofchilditemsforaniteminoneclick.
Content
BranchTemplates
Walkthrough:CreatingaBranchTemplate
1. Openhttp://BasicSitecoreinSitecoreRocks.Ifitdoesnotalreadyexists,createadatatemplatenamed
BicycleandsetitasaninsertoptionontheTripDetailsstandardvalues.
2. Tocreateanewbranchtemplate,navigateto/sitecore/templates/Branches/UserDefined(ensurethat
HiddenitemsischeckedintheViewtab)andselectNewBranch.
3. SelecttheTripDetailsdatatemplateasyourstartingpoint,andclickCreate.
4. Clickonthe$nameitemthatusesaglobeicon.ClicktheHometab.YouwillseeBicycleasaninsert
option.InsertthreeBicycleitemscallthem$nameBikeoption1,$nameBikeoption2and$nameBike
option3.

Inthiswalkthroughyouwilllearnhowto:
CreatebranchtemplatesintheTemplateManager.
AssignanewbranchtemplateasaninsertoptionfortheTripDetailsdatatemplate.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 216
KnowledgeCheck
Whatwillhappentothe$nametokenwhenanitemiscreatedbasedontheTripDetailsbranchtemplate?
5. AssignthisTripDetailsbranchtemplateasaninsertoptionfortheHolidaysSection.
6. Let’screateaninstanceofthisbranchtemplate.Navigateto/sitecore/content/home/FamilyHolidaysitem
and,fromtheinsertoptions,selecttheTripDetailsbranch.
7. GivethetripanamesuchasExperienceBudapest’.
8. Anewsubtreehasbeencreatedandall$nametokenshavebeenreplacedwithExperienceBudapest:
Note
Branchtemplatescanbeassignedasinsertoptionsonstandardvaluesinexactlythesamewayas
regulartemplates.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 217
OtherItemandTemplateProperties
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Explainlanguageversions.
Discussnumberedversions.
Statethreetypesoffieldversioning.
Explainthepurposeofsettingthefieldsource.
Describewheretosetfieldsorting.
Discusswheretosethelpertext.
Content
LanguageandNumberedVersions
 
Important
Forcontenttoexistyouneedtohavealanguageversionandatleastonenumberedversionofthe
content.
Youmayhaveawebsitewherecontentisneededintendifferentlanguages.Insteadofcreatingten
individualwebsitesforeachlanguageorusing.NETresourcefiles,youcanaddlanguagestotheSitecore
implementationwithoutthedeveloper’sinvolvement.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 218
DemoLanguagesandNumberedVersions
Thefollowingdemosusethehttp://BasicSitecoreinstance.
LanguagesandNumberedVersions
1. UsingSitecoreRocks,rightclickthemasterdatabaseandselectTools>Manage.
2. RightclickintheeditorpaneandselecttheAddNewLanguage…>Danish.
3. NavigatetotheExploreHollanditemandswitchbetweenthelanguages.Noticethereisnocontent
showingfortheDanishlanguagebecausethereisnonumberedversionunderit.
4. FortheDanishlanguage,youneedtoaddanewnumberedversionofthecontentsorightclickinthe
editorpaneandselectVersions>AddVersion.
5. Switchlanguagesinthebrowserusingsc_langquerystring(?sc_lang=daDK).
FieldVersioning
WhatiftravelagentsneededauniqueIDforeverytrip
detailsitem?Youwouldnotwantauthorsto
havetoretypeanIDeverysingletimetheycreateanewnumberedversionofthatitem,oranew
language.Theycaneasilymakemistakesandthisiswheresharedfieldscomein.
1. IntheTripDetailsdatatemplate,createanewfieldsectioncalledHolidayAdminandafieldcalled
HolidayID,whichisshared(singlevalueforallversionsinalllanguages).
2. EnteradefaultvaluefortheHolidayIDfield.
3. NavigatebacktoExploreHollandandswitchbetweenthelanguageandnumberversions,andnotice
thatthefieldvalueisthesame.
4. Amonthhaspassedandyouneedanewnumberedversionofthecontent.CreateV#2inDanish.
5. SwitchbetweenDKv#1andDKv#2(samefieldvalue).
Inthisdemoyouwillsee:
Thatyoucanhavecontentindifferentlanguages.
Howtocreateanumberedversion
Howfieldversioningworks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 219
BusinessUseCase
Whatifyouhaveafieldwithanameofacountrythatyouwanttokeepthesameforallnumbered
versionsinaparticularlanguage?Forexample,thecountryitselfdoesn’tchange,buteverylanguage
mayspellacountrynamedifferently.Thisiswhereunversionedfieldscomein.
6. IntheTripDetailsdatatemplate,createanewfieldcalledCountry,whichisUnversioned(singlevalue
perlanguage).
7. EnteradefaultvaluefortheCountryfield.
8. NavigatebacktoExploreHollandandswitchbetweenthelanguageandnumberversions.Noticethe
EnglishversionisdifferentfromtheDanishone,whichisempty.
9. FillintheDanishfieldwithUSA.
10. SwitchtoEnglishv#1(differentvalue).
FieldVersioning
Tip
Ifyouhaveanitemrepresentingasetting,forexampleaCSSclass,youwouldwantthattobethesame
acrossalllanguagesforthatitem.Thisisagoodcandidateformakingafield‘Shared’and‘Unversioned’
meaningit’sthesameacrossalllanguages,andthereisonlyonenumberedversionofthatitem.Note
thatasharedfieldisautomaticallyunversioned.

The
HolidayID
fieldisthe
same
for
alllanguages
and
allnumberedversions,whereasthe
Country
fieldis
languagespecific,samevalueforeachlanguageandeachversionnumberunderit.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 220
DemoHelpingAuthors
Thisdemousesthehttp://BasicSitecoreinstance.
FieldSorting
1. Inthe__StandardValuesitemfortheTripDetailsdatatemplatenoticetheorderofthefieldsections
BasicInformationandTripInformation.
2. Tochangethesortingorderweneedtogotothedefinitionofthosefieldsections.Navigateto
/sitecore/templates/UserDefined/TripDetails/TripInformation,rightclickintheEditorpane,andinthe
contextmenu,selecttheStandardFieldsoption.
3. Inthestandardfieldslookforthe_SortorderfieldintheDatafieldsection.
4. Changethevalueto0(bringingthatfieldsectiontothetop).
5. Doubleclick/sitecore/templates/UserDefined/Base/BasicInformation,andchangethevalueof_Sortorder
fieldto10(bringingthatfieldsectionbeneathTripInformation).
6. Openupthe__StandardValuesitemfortheTripDetailsdatatemplateandnoticethatyourfield
sectionshavenowchangedorder.
7. Lastly,rightclickagainintheEditorpaneandcleartheStandardFieldscheckbox.
HelpText
1. IntheContentEditor,doubleclicktheTypefielddefinitionitem/sitecore/templates/UserDefined/Trip
Details/TripInformation/Priceperpersonandrightclicktoviewthestandardfields.
2. FindtheHelpfieldsection.Inthe__Shortdescriptionfield,type:Thismusthavetwodecimalplaces.
3. Inthe__Longdescriptionfield,type:Avalidationrulewillensurethatthisfieldhastwodecimalplaces.
4. Previewabicycleitemorcreateanewbicycleitem.Youshouldseefieldsamended.
Tip
UsingtheContendEditor,aquickerwaytogettothehelpfieldsistoselectthefielddefinitionitemsin
thetree.Butinsteadofviewingstandardfields,youcanclickontheConfiguretabandthehelpcommand.
ThisopensuptheHelpfieldsection.
Inthefollowingdemo,wewill:
Sortfields.
Addhelptexttofields.
ChangetheTitleofafieldtosomethingmoreintuitive.
Inthisdemoyouwillseethatfieldshaveasortingorderandcanbereorderedfordisplayintheeditorpane.
Inthisdemoyouwillseethatfieldscanhavehelpertextaddedtothem
tohelpauthorsfillinfields.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 221
TitleField
1. Navigateto/sitecore/templates/UserDefined/TripDetails/HolidayAdmin/HolidayIDdefinitionitem.
2. IntheTitlefield(Datafieldsection)enterBookingreferencenumber.
3. ClicktheSavebutton.
4. PreviewanyitemintheContentEditor.
SortingFields

Ifyouwanttocompletelychangethefieldnamethatisdisplayedtoauthors,youcandothatinthe
Title
field.Forexample,youcanchangeHolidayID(whichdeveloperswillstilluseandsee)toBookingreference
number(whichiswhatauthorssee).
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 222
ShowStandardFields
 
HelpText
TitleField
 
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 223
Tip
Youcancreatedefaultvaluesforlanguagespecificitemsonthestandardvalues.Forexample,the
defaultpageimagefieldforEnglishisimageA,andforGermanit’simageB.Thisisdonebycreatingnew
numberedversionofthatlanguageinthestandardvalues.
ApplyTopic11.235min
WorkingwithVersions,Sorting,HelpFields,andFieldSource
LabA. AddaNewLanguageandSomeNumberedVersions
1. Gobacktothehttp://BasicSitecore/siteyoucreatedondayone.ExpandtheBasicSitecoreinstance
nodeinSitecoreRocks.
2. UsingSitecoreRocks,rightclickthemasterdatabaseandselectTools>Language.
3. RightclickinthecontentpaneandselecttheAddNewLanguage…option.
4. SelecttheDanishlanguage.
5. NavigatetotheExploreHollanditemandswitchbetweentheEnglishandDanishlanguage.
6. FortheDanishlanguage,youneedtoaddanewnumberedversionofthecontent.Rightclickinthe
EditorpaneandselecttheVersions>AddVersionoption.
Inthefollowinglabsyouwillbe:
Addinganewlanguage.
Changingfieldanditemversioning.
AlteringthesortorderfortheBicycletemplate.
SettinghelpertextforyourBicycleInformationitem.
Changingthetitlefieldofaparticularfielddefinitionitem.
Language
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 224
7. Thefieldsyougetinanewversionareblankbecausethefieldvalueshavenotbeendefinedonthe
standardvaluesforthatparticularlanguage.Entersomevaluesforthefields.
8. IntheTripDetailsdatatemplate,createanewfieldsectioncalledHolidayAdminandtwonewfields
calledHolidayID,whichisShared(singlevalueforallversionsinalllanguages),andafieldcalled
CountrywhichisUnversioned(singlevalueperlanguage).
9. EnteradefaultvaluesfortheHolidayIDandtheCountryfieldsintheStandardfields.
10. NavigatebacktoExploreHollandandswitchbetweenthelanguageandnumberversions.Noticethat
theHolidayIDvalueisthesamebetweenlanguages,buttheCountryvalueinEnglishisdifferentfrom
theDanishone,whichisempty.
11. FillintheDanishfieldwithUSA.
9. SwitchtoEnglishv#1(differentvalue).
10. CreateV#2inDanishbyrightclickingtheEditorpaneandthenselecttheVersions>AddVersion
option.
11. SwitchbetweenDKv#1andDKv#2(theyshouldbethesamevalueUSA).
LabB. FieldSource
1. IntheContentEditor,navigatetoacontentitemsuchasExploreHollandat:
/sitecore/content/Home/FamilyHolidays/ExploreHolland.
2. Changetheimageandnotethebrowsinglocation.
3. ClosethatandnavigatetotheExploreHollanddatatemplateusingtheQuickInfosection.
4. RememberweareinheritingthatimagefieldfromtheBasedatatemplate,sonavigatetoBase.
Inthislab,youwillspecifyalocationofwhereyourauthorscanselectimages.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 225
5. Changethefieldsourcetobethelocationofafolderinmedialibrary.
Tip
YoucanusetheitempathinthetreeortheGUIDforfieldsource.Therearedifferentfieldsources
dependingondifferentfieldtypes.Wewillcoverthislaterinthecourse.
6. Inthesourcefieldtype/sitecore/medialibrary/ImagesorusetheGUIDofthatitem.
7. GobacktoExploreHollandandbrowsetoanimageorcheckthestandardvalues.Notethechangeof
location.
LabC. ChangingtheSortOrder
1. Viewthe__StandardValuesitemfortheTripDetailsdatatemplate.
2. NotetheorderofthefieldsHolidayIDandCountryintheHolidayAdminsection.Wearegoingtoswap
theirorder.
3. DoubleclicktheHolidayIDitemat:/sitecore/templates/UserDefined/TripDetails/HolidayAdmin/Holiday
ID.
4. Rightclickinsidetheeditingpanetoviewthestandardfields.
5. Changethe__Sortorderfieldto20.
6. DoubleclickontheTypeitemat:/sitecore/templates/UserDefined/TripDetails/HolidayAdmin/Country.
7. Changethe_Sortorderfieldto200.
8. RightclickagaintocleartheStandardFieldscheckbox.
9. Openupthe__StandardValuesitemfortheBicycledatatemplate,andnoticethatyourfieldshavenow
changedorder.
InthislabyouwillchangethesortorderoftheBicyclefields.

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 226
Tip
Youcanchangethesortorderoftemplatesectionsinexactlythesameway.Aswellasmanually
updatingthesortorderfields,youcanrightclickonitemsinSitecoreRocksandchooseTools>Sorting
toselecttheoptionsthere.Thelowerthenumberthehigheritappearsinthehierarchy.
LabD. HelpFields
1. UsingtheContentEditor,doubleclicktheTypefielddefinitionitemat:/sitecore/templates/User
Defined/TripDetails/HolidayAdmin/HolidayIDandontheribbon,selectView>StandardFields.
2. FindtheHelpfieldsectionandthe__Shortdescriptionfield.EnterThisistheIDfromyourexternalfeed.
3. ClickSave.
4. DoubleclicktheCountryfielddefinitionitemat:/sitecore/templates/UserDefined/TripDetails/Holiday
Admin/Country.
5. FindtheHelpfieldsectionandthe__Shortdescriptionfield,enterRememberthatthecountrynameis
translated.
6. Save.
7. Lookatanexistingbicycleitemandyouwillseethehelptextappearnexttothefields.
LabE. TitleField
1. IntheContentEditor,navigateto:/sitecore/templates/UserDefined/TripDetails/HolidayAdmin/Holiday
IDdefinitionitem.
2. IntheTitlefield(Datafieldsection),enter:Bookingreferencenumber.
3. ClickSave.
4. PreviewanyitemthathasthatfieldintheContentEditor.


InthislabyouwilladdsomehelptexttoyourBicycleInformationfieldsusingthe
ContentEditor.
Inthislabyouwillchangethewaythefieldnameisdisplayedtoauthors,howeveryourfielddefinitionwill
staythesame.Thisisparticularlyusefulincaseauthorsneedalongerdescriptionforafieldbutasa
developeryoustillreferenceadifferentname/ID.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 227
PipelinesandEvents
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Definepipelinesandevents.
Describewheretoconfigurepipelinesandevents.
Describethetypeformatforthe<processor/>.
Namethemostimportantpipeline.
Namethemethodthatallprocessorsimplement.
Statewhichfilesareusedtopatchyourprocessorintothepipeline.
Listthreeoptionsforcreatingpipelines.
Content
IntroductiontoPipelines
 
Processor
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 228
CreatingPipelinesOption1

CreatingPipelinesOptions2&3
Important
UpgradingSitecoremaychangetheoriginalcodethatyouareinheritingfrom,whichmeansthatyour
pipelinemayneedupdating.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 229
IntroductiontoEvents
 
SubscribingtoEventsandUsingEventHandlers
Tip
ForanexampleofhowtocreateanInsertOptionspipeline,seeTheDataDefinitionCookbook:
http://sdn.sitecore.net/upload/sitecore6/datadefinitioncookbooka4.pdf
Formoreinformationaboutevents,seeJohnWest’sblog:
http://www.sitecore.net/Learn/Blogs/TechnicalBlogs/JohnWestSitecoreBlog/Posts/2011/05/AllAbout
EventsintheSitecoreASPNETCMS.aspx
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 230
WhenWouldYouUsePipelinesorEvents?

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 231
Rules
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Definearule.
Namethetwofieldsthatdefinearule.
Content
SitecoreRulesEngine&Rules
 
HowDoesaRuleWorkforAuthors?
 
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 232
Walkthrough:ImplementationofInsertOptionsRule
1. CreateanewInsertOptionRulecalledLink.
2. IntheNamefieldenterLinks.
3. IntheRulefieldenter:
WheretheitemnameisequaltoLinks.
addSimpleLinkinsertoption
(/BaseCore/GlobalContent/SimpleLink).
4. Under:/sitecore/content/sitecorecycling
holidays/GlobalcreateaLinksitemusingthe
commonSitecorefolder.
5. NoticetheinsertoptionincludesSimpleLink.
6. Therearemanyotherconditionsandactionsthatareusefulregardlessofwhatthepurposeorcontextof
theruleis.Thosearedefinedunderacommonfolder:
/sitecore/system/settings/rules/common/Conditions/Items.FindItemName,whichistheruleweusedin
step#3.
BusinessUseCase
Ecommercewebsitevisitorshaveashoppingcartandbasedonwhattheyhave
purchased,youcanchangewhatisdisplayedinacomponent.
Haveatreestructurefornewsarticles,forexample,Year,Month,Day.Whenan
authorcreatesanewnewsarticleatthetoplevelofthisstructure.Usingarule,this
articlecanbeslottedintoitscorrespondingfolder.
HideInsertoptionsbasedonwhatlevelthetreeison.
Youmaywishtoboostitemswhenindexingdataby.Forexample,youmightusea
ruletoapplyadifferentboostdependonanitem’slevelinthehierarchy:
http://www.sitecore.net/Community/TechnicalBlogs/JohnWestSitecore
Blog/Posts/2013/05/Sitecore7BoostingItemsByDepthwiththeRules
Engine.aspx
Extend
Rulesenginecookbook
http://sdn.sitecore.net/Reference/Sitecore%206/Rules%20Engine%20Cookbook.aspx

Inthefollowingwalkthrough,wewill:
CreateaninsertoptionsrulethataddsSimpleLinkasaninsertoptiontoanyitemwhose
nameequalsLinks.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 233
PlaceholderOverrides
Introduction
Objectives
Bytheendofthistopicyouwillbeableto:
Overrideaplaceholdersettingforaparticularitem.
Content
Demo:CreatePlaceholderSettingOverride
1. InPageEditorlookattheHomeitemcomponentcalledGalleryinthegallerycontainerplaceholder.
2. Noticethatyoucanaddbannerandgallerycomponenttothatplaceholder.
3. Gotoanotheritemandshowthatyoucanstilladdbannerandgallerytothegallerycontainer
placeholder.
4. Let’ssayforthispageyouarenotallowedtoaddagalleryand
youonlywantstaticimagetoappear.Navigatetothegallery
containerplaceholder,clickCreateNewSettingscallit
gallerycontainerbanneronlyandedittheallowedcontrolsto
allowBannertobetheonlycomponent.
5. Savethepage.
6. Noticetheplaceholdernamechangedto:gallerycontainer
banneronly.
7. NowwhenyouclickAddtohereyouonlyseeBanner.
8. Navigatebacktohome,showtheoldplaceholderwithits
options.
9. SwitchtotheContentEditorandshowthenewplaceholderitemthatwascreatedinthebackground.
Inthefollowingwalkthrough,wewill:
Createanewplaceholdercontrolinthemarkup.
Createaplaceholderoverride,whichineffectisaduplicateoftheoriginalplaceholder,
withdifferent“allowedcontrols”perinstanceofanitem.Youcanalsosetituponthe
standardvaluessothateveryitemwouldgetthisoverride.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 234
WhatarePlaceholderOverridesUsedFor?
 
Tip
Generally,youtendtospecifyoverridesontheitem’stemplate’sstandardvalues,butyoucanspecify
placeholderoverridesperitem.
HowtoOverrideaPlaceholderSetting
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 235
IntheContentEditor
 
WheretoOverridePlaceholderSettings
 

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 236
ApplyTopic11.520min(OPTIONAL)
CreatePlaceholderSettingOverride
AchangerequesthascomeintorestrictauthorstobeabletoaddonlytheBannercomponenttothe
gallerycontainerplaceholderforalltheholidaypages.
1. OpenTraincore.InthePageEditornavigateto:/Sitecorecyclingholidays/Home/holidays/battleofthe
hills
2. MakesureyouareinDesignmode.
3. Ontheholidaypage,clicktheBannercomponent,andnavigatetothegallerycontainerplaceholder
usingthearrowicon.
4. ClickAddtohere.
5. AsanauthoryouareallowedtoaddonlyaGalleryoraBannercomponentintothisplaceholderclick
cancelthinkofitasInsertOptionsforaplaceholder.
6. Selectthegallerycontainerplaceholderagainand,thistime,clickthecommandontheribbontoEdit
theplaceholdersettings.
7. ClicktheCreateNewSettingstab.
ItisimportanttoensurethatpresentationdetailsareconfiguredcorrectlyforthePageEditor.Thisinvolves
settingupplaceholdersettingsandplaceholdersettingsoverrides.
Ascenarioforoverridingaplaceholder
Youhavecreatedaholidayspage,andithasusedtheglobalplaceholdergallerycontainer
Fortheholidayspage,youonlywanttoallowauthorstoputthe‘banner’componentonthepage.
Butthegallerycontainerplaceholderhasnorestrictionsonit;itallowsauthorstoaddaBannerand
aGallerycomponent.
Youwanttosetthisrestrictionforallholidaypages‐globally.
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 237
8. Namethenewplaceholdergallerycontainerbanneronly.
9. Intheallowedcontrols,youcanspecifytheallowedcontrolsthatthisplaceholdercanhave.Setthe
Bannercomponentasanallowedcontrol.Thepathis:Layout/Renderings/BaseCore/BannerandclickOK.
10. Savetheitem.
11. Confirmthattheplaceholderusednowisthenewone.
12. ClicktheAddtoherebuttontoconfirmthatonlyBanneristheonlyallowedcontrol.
CopythePlaceholderOverridetotheStandardValues
1. StayinthePageEditor.Ontheribbon,selecttheAdvancedtabandclickDetails.
2. FortheDefaultdevice,clickCopyToatthebottomofthatdevice.
3. ChecktheDefaultDevicecheckboxandselectthestandardvaluesforthatholidaypage.Thepathis:
/Templates/BaseCore/Pages/Holiday/__StandardValues.

Namethenew
placeholder
2
Settheallowedcontrols
3
Createanew
placeholder
settingsitem
1
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 238
4. ClickCopythenOKintheLayoutDetailsdialog.
5. Ifyouaddanewholidaypage,itwillautomaticallygetthegallerycontainerbanneronlyplaceholder.
Tip
Ifyouwantaplaceholderoverridetoapplytoallitemsbasedontheholidaydatatemplate,modifythe
presentationdetailsontheholidaydatatemplate’sstandardvalues.Addanewplaceholdersettingthat
overridesgallerycontainer;thischangewillthenbereflectedonallnewsitems.
Selectthe
Defaultdevice
1
Selectthe
required
__Standard
Valuesitem
2
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 239
Review
Contents:
Module1SitecoreOverview
Module2DefiningData
Module3Presentation
Module4SitecoreAPI
Module5AdvancedPresentationConcepts
Module6RealWorldSolutions
Module7ConfiguringthePageEditor
Module8DealingwithYourData
Module9RecommendedPractices
Module10MarketingFunctionality
Module11OptionalTopics

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 240
Module1SitecoreOverview
Topic1.2WhatIsSitecore
Topic1.3SitecorefromanAuthor’sPerspective
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 241
Topic1.4SitecorefromanDeveloper’sPerspective
Module2DefiningData
Topic2.1 DefiningDataStructure
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 242
Topic2.2DataTemplateInheritance
Topic2.3 StandardValues
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 243
Topic2.4 InsertOptions
Module3 Presentation
Topic3.1 PresentationIsDynamicandModular

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 244
Topic3.2 PreparingtoBuild
Topic3.3 CreatingaLayout

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 245
Topic3.4 CreatingComponents
Topic3.5 DynamicBinding

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 246
Topic3.6 OutputtingContent
Module4SitecoreAPI
Topic4.1 BasicAPIConcepts

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 247
Topic4.1(continued)RetrievingItems
Topic4.2 ItemLinks

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 248
Topic4.3 Creating,DeletingandModifyingItems
Topic4.4 WorkingwithComplexFields
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 249
Module5 AdvancedPresentationConcepts
Topic5.1Datasources
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 250
Topic5.2 LayoutDeltas
Module6 RealWorldSolutions
Topic6.1FamiliarConcepts
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 251
Topic6.2DealingwithLargerSites
Topic6.3SitecoreQuery
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 252
Module7 ConfiguringthePageEditor
Topic7.1DatasourceRestrictions
Topic7.2ParametersandParameterTemplates
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 253
Topic7.3PlaceholderRestrictions
Topic7.3(continued)CompatibleRenderings/AllowedControls
Topic7.4AdvancedPageEditorConfiguration
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 254
Module8 DealingwithYourData
Topic8.1ItemBuckets
Topic8.2Search
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 255
Module9 RecommendedPractices
Topic9.1WorkingwithMedia
Topic9.2CachingandPerformance

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 256
Topic9.3Publishing
Topic9.4InstallingandScalingSitecore
Topic9.5TeamDevelopmentandDevelopmentEnvironment

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 257
Topic9.6HowtoDealwithDeployment
Topic9.7Security
Topic9.8Workflows
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 258
Module10 MarketingFunctionality
Topic10.1IntroductiontotheXP
Topic10.2EngagementValueandGoals

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 259
Topic10.3ProfilingandPersonalization
Module11 OptionalTopics
Topic11.1BranchTemplates

SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 260
Topic11.2OtherItemandTemplateProperties
Topic11.3PipelinesandEvents
SitecoreOfficialCurriculumWebsiteDevelopmentfor.NetDeveloper
©Sitecore20147.2.0.1 261
Topic11.4Rules
Topic11.5PlaceholderOverrides

Navigation menu