How to create a simple symlink page component

Question

How is it possible to create a simple symlink component that lets users create symlinks to other existing pages?

Answer, Resolution

In order to build a simple symlink component that allows for creating a symlink page, a simple page component with following code is sufficient:

com.day.cq.wcm.api.WCMMode mode = com.day.cq.wcm.api.WCMMode.DISABLED.toRequest(request); 
try { 
    %><sling:include path="/content/geometrixx/en/products" /><% 
} catch (Exception e) { 
    log.error("Exception while including target", e); 
} finally { 
    mode.toRequest(request); 
} 

In above example, the content page located at /content/geometrixx/en/products will be displayed as a hard-coded reference. The symlink page itself is displayed in read-only mode, the edit functionality is disabled.

Please note that this is just an example showing the basic principle. What is missing for example is a dialog which allows users to choose the symlink target and so on.

Applies to

CQ5.x

 Adobe

Saage abi kiiremini ja hõlpsamalt

Uus kasutaja?