Professional Sitecore 8 Development.pdf - Professional Sitecore 8 Development A Complete Guide to Solutions and Best Practices \u2014 Phil Wicklund Jason

Professional Sitecore 8 Development.pdf - Professional...

This preview shows page 1 out of 440 pages.

You've reached the end of your free preview.

Want to read all 440 pages?

Unformatted text preview: Professional Sitecore 8 Development A Complete Guide to Solutions and Best Practices — Phil Wicklund Jason Wilkerson Foreword by John West Professional Sitecore 8 Development A Complete Guide to Solutions and Best Practices Phil Wicklund Jason Wilkerson Professional Sitecore 8 Development: A Complete Guide to Solutions and Best Practices Phil Wicklund Minneapolis, Minnesota, USA Jason Wilkerson Minnetrista, Minnesota, USA ISBN-13 (pbk): 978-1-4842-2291-1 DOI 10.1007/978-1-4842-2292-8 ISBN-13 (electronic): 978-1-4842-2292-8 Library of Congress Control Number: 2016959582 Copyright © 2016 by Phil Wicklund and Jason Wilkerson This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Acquisitions Editor: Susan McDermott Developmental Editor: Laura Berendson Technical Reviewer: Kamruz Jaman, Mike Reynolds, Nick Wesselman Editorial Board: Steve Anglin, Pramila Balen, Laura Berendson, Aaron Black, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing Coordinating Editor: Rita Fernando Copy Editor: Kezia Endsley Compositor: SPi Global Indexer: SPi Global Cover Image: Selected by Freepik Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit . Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit . Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at . Any source code or other supplementary materials referenced by the author in this text is available to readers at . For detailed information about how to locate your book’s source code, go to source-code/. Printed on acid-free paper I dedicate this book to my mother, who unceasingly drilled into me: “If there’s a will, there’s a way!” —Phil I dedicate this book to my wife, Anna. Without you, I could never have accomplished this. For real. Also, to the Sitecore Community; your passion and excitement is infectious and it drives me. —Jason Contents at a Glance Foreword ............................................................................................................... xiii About the Authors....................................................................................................xv About the Contributor ............................................................................................xvii About the Technical Reviewers ..............................................................................xix Acknowledgments ..................................................................................................xxi Introduction ..........................................................................................................xxiii ■Chapter 1: Getting Started ..................................................................................... 1 ■Chapter 2: Building Your First Component .......................................................... 39 ■Chapter 3: Data Templates and Content .............................................................. 77 ■Chapter 4: Back-End Dev Architectures ............................................................ 115 ■Chapter 5: Improving the Design with Patterns ................................................ 151 ■Chapter 6: Front-End Dev Techniques ............................................................... 187 ■Chapter 7: Unit Testing Sitecore ........................................................................ 209 ■Chapter 8: Search-Driven Solutions .................................................................. 241 ■ Chapter 9: Programming the Customer Journey ............................................... 279 ■Chapter 10: Sitecore PowerShell Extensions..................................................... 319 ■Chapter 11: Extending the Experience Editor .................................................... 379 Index ..................................................................................................................... 419 v Contents Foreword ............................................................................................................... xiii About the Authors....................................................................................................xv About the Contributor ............................................................................................xvii About the Technical Reviewers ..............................................................................xix Acknowledgments ..................................................................................................xxi Introduction ..........................................................................................................xxiii ■Chapter 1: Getting Started ..................................................................................... 1 What Is Sitecore? ............................................................................................................. 1 Developer Platforms versus Portal Solutions ......................................................................................... 3 Sitecore’s Key Features and Capabilities ............................................................................................... 4 Infrastructure and Services Architecture Options................................................................................... 9 A Tour of the Sitecore Admin Interface ................................................................................................. 15 What’s New in Sitecore 8?.................................................................................................................... 18 The Sitecore Hierarchy ................................................................................................... 20 Templates ............................................................................................................................................. 21 Content ................................................................................................................................................. 23 Layouts and Components ..................................................................................................................... 24 Setting Up Your Development Environment .................................................................... 27 Tools Every Sitecore Developer Needs ................................................................................................. 27 Setting Up SQL Server .......................................................................................................................... 27 Installing Sitecore ................................................................................................................................. 31 Summary ........................................................................................................................ 38 vii ■ CONTENTS ■Chapter 2: Building Your First Component .......................................................... 39 Building a View Rendering ............................................................................................. 39 Working with Layouts and Placeholders............................................................................................... 39 Creating a Component .......................................................................................................................... 51 Deploying to Sitecore ........................................................................................................................... 52 Adding a Component to a New Page .................................................................................................... 54 Building a Controller Rendering ..................................................................................... 61 Controller Renderings versus View Renderings.................................................................................... 61 Creating a Controller Rendering ........................................................................................................... 62 Summary ........................................................................................................................ 75 ■Chapter 3: Data Templates and Content .............................................................. 77 Data Template Fields ...................................................................................................... 77 Field Sections ....................................................................................................................................... 78 Field Types ............................................................................................................................................ 79 Custom Field Types ............................................................................................................................... 83 Field Sources ........................................................................................................................................ 90 Field Versioning .................................................................................................................................... 90 Field Validation ..................................................................................................................................... 90 Custom Field Validators ........................................................................................................................ 92 Data Template Inheritance.............................................................................................. 95 Working with Standard Values ....................................................................................... 97 Configuring Default Values ................................................................................................................... 98 Configuring Insert Options .................................................................................................................. 103 Templates and Configurations ...................................................................................... 103 Creating Our Branch Templates .......................................................................................................... 103 Content Management Fundamentals ........................................................................... 105 Where Do You Manage Content? ........................................................................................................ 105 Architecting Your Content Tree ........................................................................................................... 107 Managing Rich Media ......................................................................................................................... 109 Content Personalization ...................................................................................................................... 110 Content Versioning.............................................................................................................................. 111 viii ■ CONTENTS Content Approval and Publishing Workflows ...................................................................................... 112 Content Optimization .......................................................................................................................... 112 Deleting and Archiving Content .......................................................................................................... 112 Content Cloning .................................................................................................................................. 113 Multilingual Content Translations ....................................................................................................... 113 Summary ...................................................................................................................... 114 ■Chapter 4: Back-End Dev Architectures ............................................................ 115 The Model-View-Controller Design Pattern .................................................................. 115 Sitecore Modular Architecture...................................................................................... 123 Setting Up Your Solution ............................................................................................... 128 Stubbing Out a Web Project ................................................................................................................ 128 Creating Your First Module ................................................................................................................. 142 Deploying Your Code ........................................................................................................................... 145 Summary ...................................................................................................................... 149 ■Chapter 5: Improving the Design with Patterns ................................................ 151 Refactoring: Incorporating the Repository Pattern ....................................................... 151 Refactoring: Incorporating a Service Layer Pattern ..................................................... 158 Refactoring: Incorporating Object-Relational Mapping ................................................ 169 Refactoring: Incorporating Generics ............................................................................. 174 Refactoring: Incorporating Inversion of Control............................................................ 180 Summary ...................................................................................................................... 186 ■Chapter 6: Front-End Dev Techniques ............................................................... 187 Presentation and Applying Layouts .............................................................................. 187 Razor, CSS, JavaScript, and Gulp .................................................................................. 195 Programming Razor and Forms .......................................................................................................... 195 Getting CSS and JS on a Page ............................................................................................................ 202 CSS and JS Minification with Gulp ..................................................................................................... 202 AngularJS ........................................................................................................................................... 206 Summary ...................................................................................................................... 208 ix ■ CONTENTS ■Chapter 7: Unit Testing Sitecore ........................................................................ 209 Getting Started Unit Testing.......................................................................................... 210 Making Tests Easier to Read with FluentAssertions ........................................................................... 213 Creating Dummy Data, the Easy Way, with AutoFixture ...................................................................... 214 Isolating Tests with Moq ..................................................................................................................... 216 Unit Testing a Service ................................................................................................... 218 Refactoring to Include a Service Test Harness ................................................................................... 222 Unit Testing a Controller ............................................................................................... 225 Refactoring to Include a Controller Test Harness ............................................................................... 229 Sitecore FakeDb ........................................................................................................... 233 Summary ...................................................................................................................... 239 ■Chapter 8: Search-Driven Solutions .................................................................. 241 Setting Up Your Index ................................................................................................... 241 Searching Your Index .................................................................................................... 246 Creating a Computed Field ........................................................................................... 259 Adding an Autocomplete .............................................................................................. 268 Refining Results with Faceted Search ......................................................................... 271 Summary ...................................................................................................................... 278 ■Chapter 9: Programming the Customer Journey ............................................... 279 Extending Web Forms for Marketers ............................................................................ 280 Programing Goals, Events, and Outcomes.................................................................... 291 Custom Personalization Rules ...................................................................................... 294 Extending Engagement Plans ....................................................................................... 300 Programming the xDB Contact ..................................................................................... 304 Identifying a Contact........................................................................................................................... 304 Using Custom Tags .............................................................................
View Full Document

  • Summer '19
  • none
  • Content management system, web content, Sitecore

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture