How do I find the parent of a content node?

ContentNodeUtil provides methods to find out the parent of a content node as well as its renderable parent the parent of a content node (typically a sv:layout) as well as the renderable parent (typically a sv:page)

ContentNodeUtil has methods to find the parent of a content node. The method getContentParent you will find the parent content node (typically a sv:layout). The method getRenderableParent finds the content node's renderable parent (typically a sv:page)

Step 1 - Get an instance of ContentNodeUtil

For WebApp/RESTApp 2; use import:

import contentNodeUtil from '@sitevision/api/server/ContentNodeUtil';

For Script module and WebApp/RESTApp 1; use require:

const contentNodeUtil = require('ContentNodeUtil');

Step 2 - Make use of ContentNodeUtil

// A content node to find the parent of
const portlet = ...; // Lookup the sv:portlet node

// Get the content parent
const parent = contentNodeUtil.getContentParent(portlet);

// Get the renderable parent
const renderableParent = contentNodeUtil.getRenderableParent(portlet);

Do you want to subscribe to News from Sitevision Developer team? Subscribe here!