43
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. A virtual developer conference for Adobe Experience Manager Efficient Publishing with Content Fragments Stefan Grimm | Senior Developer

Immerse 2016 Efficient publishing with content fragments

Embed Size (px)

Citation preview

Page 1: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

A virtual developer conference for Adobe Experience Manager

Efficient Publishing with Content FragmentsStefan Grimm | Senior Developer

Page 2: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Efficient Publishing with Content Fragments

2

1 | Welcome and Overview

2 | Content Fragments - a brief introduction

3 | Use case: A news site

4 | Implementing an efficient workflow

5 | Q&A

Page 3: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3

Content FragmentsA brief introduction

Page 4: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4

Ecosystem

Page 5: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 5

Simple fragment template Generic component Typical AEM workflow required First, create the fragment Then, create a page, add the fragment to the page, configure it, etc.

OOTB

Page 6: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6

Some use-cases require a more efficient workflow. OOTB component can be too generic Too much flexibility Not enough flexibility

ข Some use-cases require customization

Customizing the component Implement a specific workflow

Context

Page 7: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7

Use-case:A (imaginary) news site

Page 8: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 8

Our goal …

Page 9: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9

Create article. Enter title. Teaser. Text. Assign image(s). Classify. Save. Create page. Add Content Fragment. Reference article. Publish.

Efficiency!

let’s get rid of these steps!

add this new feature

Page 10: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 10

Our news site

Section

Title

Teaser

Image

Text

Page 11: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 11

Fragment Elements Title Teaser Text

Metadata Section

Associated Content Image (tagged)

Articles

defining the article imagedefining the article image

Page 12: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 12

Article template Article component Page component A patched version of the CFM implementation bundle Required for AEM 6.2 only, will be included in upcoming releases

Prerequistes

Introduced in the ”Introducing Content Fragment” session

Page 13: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on …Prerequisites

13

Page 14: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14

Implementation

Page 15: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

No production-ready codein this session!

Disclaimer

15

Page 16: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 16

Problems & solutions

Page 17: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 17

How to determine the article image? Only collections, no 1:1 assignment for associated content

How to automate …? page creation adding Content Fragment component referencing & configuring the article fragment publishing the page

Problems ...

Page 18: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 18

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

... and solutions

Page 19: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 19

Finding the article image

Page 20: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 20

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

Recap

Page 21: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 21

Getting associated collections:Iterator<Resource> collections = fragment.getAssociatedContent();

Getting all associated resources:SlingScriptHelper ssh = getSlingScriptHelper();ContentFragmentManager cfm = ssh.getService(ContentFragmentManager.class);List<Resource> assets = cfm.resolveAssociatedContentFlat(fragment);

API – Accessing associated content

Page 22: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Finding the article image

22

Page 23: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 23

Workflow commons

Page 24: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 24

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

Recap

Page 25: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 25

Can be registered on low level events node create node update

Can‘t use directly intermediate saves but workflow should only be triggered on “save”

Workflow launcher

Page 26: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 26

On save Timestamp is persisted (only if content has been modified) jcr:content/lastFragmentSave (*)

Each workflow process Executes only if there has been a “save” since the last publish workflow has been finished jcr:content/lastFragmentSave > jcr:content/lastFragmentPublish

At the end of the publish workflow Updates publish timestamp jcr:content/lastFragmentPublish

(*) patched CFM implementation bundle required

Solution

Page 27: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Workflow commons

com.adobe.immerse2016.cfm_ep.workflow.AbstractFragmentProcesscom.adobe.immerse2016.cfm_ep.workflow.FinishArticleProcess

27

Page 28: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 28

Workflow process:Resolving associated

content

Page 29: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 29

Problem:

Article image defined via collection Collections should not be used on publish

Solution:

Determine article image on save Persist path to image on fragment jcr:content/articleImage

Article image

Page 30: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Resolving dependencies

com.adobe.immerse2016.cfm_ep.workflow.ResolveDataProcess

30

Page 31: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 31

Workflow process:Creating the article

page

Page 32: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 32

Check if a page for the article has already been created If not, create a page, … Path: /<root>/<section>/<year>/<month>/<day>/<article.name>

... create the article paragraph jcr:content/par/<article.name>

... reference the article fragment. jcr:content/par/<article.name>/fileReference

Page on demand

Page 33: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Auto-create article page

com.adobe.immerse2016.cfm_ep.workflow.CreateOnDemandProcess

33

Page 34: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 34

Workflow process:Publishing the article

page

Page 35: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 35

Publish Content Fragment Page Article Image

In a clean implementation … … publish references (Tags, ...) … replicate only if modified

Publishing

Page 36: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Publish article process

com.adobe.immerse2016.cfm_ep.workflow.PublishArticleProcess

36

Page 37: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

And … Action!The new, effective publishing

process

37

Page 38: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 38

Recap

Article image Part of a collection Identified by tag Resolve collection/tag to image path for publish instance

Publishing workflow Triggered by workflow launcher Processes check for “save” event by comparing save/publish timestamps Page created on demand using a fixed/hardcoded pattern Fragment & collaterals published programmatically

Page 39: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 39

Epilogue

Page 40: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 40

Not mentioned in this session …

Dispatcher invalidation No easy OOTB solution for invalidating referencing pages Can be solved using path-based dispatcher rules

Page 41: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 41

Resources

Content Package with example code available from the “Resources” pod in Adobe Connect

Documentation Overview/Authoring Editor - https://docs.adobe.com/docs/en/aem/6-2/author/assets/content-fragments.html Page Authoring - https://docs.adobe.com/docs/en/aem/6-2/author/page-authoring/content-

fragments.html Development Templates - https://docs.adobe.com/docs/en/aem/6-2/develop/templates/content-fragment-

templates.html Extending (WIP) - https://docs.adobe.com/docs/en/aem/6-2/develop/extending/content-fragments.html

Page 42: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Q&A42

Stefan [email protected]

Page 43: Immerse 2016 Efficient publishing with content fragments

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.