Content Fragments in AEM part-2

In our previous post we saw what is Content Fragment and how to create them? In this part of Content Fragment we will see how to export the Content Fragment using the Sling Model.

How to export Content Fragment using model Expoerter?



In order to exporting the Content Fragment by using the Sling model first we have to Create Content Fragment once created and used on page then go to the content hierarchy by using the crxde and copy the entire path and open in new tab as below it will show us as Json format.

To see the Content Fragment in json http://localhost:4502/content/myproject/dd/jcr:content/root/container/container/authorcontentfragmen.json



It will return the CF in Json like below response-

{“jcr:primaryType”:”nt:unstructured”,”jcr:createdBy”:”admin”,”paragraphScope”:”all”,”jcr:lastModifiedBy”:”admin”,”elementNames”:[“authorname”,”books”,”authorbio”],”jcr:created”:”Mon Dec 13 2021 20:53:33 GMT+0530″,”text”:”Author Details Author Name Amit Kumar author1 variation Books Java AEM Spring Author Bio This is the Author 1 of these ablove books. Having 15+ years of experinece as tutor. Currrently working in highlt repotated institute situated in India.”,”variationName”:”author1″,”jcr:lastModified”:”Mon Dec 13 2021 21:01:18 GMT+0530″,”sling:resourceType”:”pstrainingsite/components/authorcontentfragment”,”displayMode”:”multi”,”fragmentPath”:”/content/dam/pstrainingsite/content-fragment/en/author-details”}



To check your model specific json add .model before the .json in the url as

http://localhost:4509/content/myproject/dd/jcr:content/root/container/container/authorcontentfragmen.model.json

How to export CF using Assets API’s

Go to your Content Fragment and remove this string from url editor.html/content/dam/myproject/ and add the add .json at the end of the url. As http://localhost:4502/api/assets/myproject/content-fragment/en/author-details.json and it will show all the CF data means every variation including Master or default one.



So the basic difference among both Ways of Exporting using, Content Fragment using model Exporter it will show only that data which is used on page while using Assets API it will show all data including variations and Master version of CF.

Version Compare, Annotations, Summarize Text, Text Statistics for content fragment.



In this post we will also see how to Compare version , Annotations, Summarize Text, Text Statistics for content fragments lets first talk abut the Version Compare by modifying the content Fragment. I will add some content 1st then I will remove.

Now go to your content Fragment and try to add some content and I have added one line of text and then save it then select the Content Fragment and in the top left click on timeline view and as shown in image just select the variation with which you want to compare the current Content Fragment and option you have to select current version.

How to use Annotation in Content Fragment



The viewer and author can add annotation for review in order to highlight the thing like if author want to flag some message to the approver and vice versa.

So go to the Content and select the text and click on the pencil remember first you have to view the content editor in full screen as below.



Then go to the annotation from left panel and you will see the annotated content with colored text.

Text statics in Content Fragment

It will se details of the content like how many words are used in the content, how many characters used, how many space used etc. It will show all statics of your content.

Go to the multifield content editor and open the editor in full screen and on top of the page you will see the text Statics button as.

Summarize the text



It will show all the content in a summarized way in that case we have to specify the length of the content then it will automatically summarize the content by removing the unwanted text in case if we enter the length of the content less then the available content length. Else it will show only that content which has original length in case if we specify the big length if the actual content.

This feature is useful for small devices like mobile and tablets to show the less content.