Back

How to Copy a Contentlet using Velocity

Description

This example shows how to use the ContentletAPI to find a Contentlet by a given inode and then copy it. Other methods from the ContentletAPI can also be used by calling: $contents.getContentletAPI().

Code

#set($contentInode = "c59d1e44-36db-4df6-bdea-d9816dab7c6d")
#set($contentlet=$contents.getContentletAPI().find($contentInode , $user, false))
#set($user = $cmsuser.getLoggedInUser($request))
#set($dummy = $contents.getContentletAPI().unlock($contentlet, $user,false))
#set($copiedContentlet=$contents.getContentletAPI().copyContentlet($contentlet,$user,false))