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

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