Logotype Sitevision Developer
Log in
Log in

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) the parent of a content node (typically a sv:layout) as well as the renderable parent (typically a sv:page)

Published: 2022-07-22  |  Updated: 2024-09-26

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 - use import:

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

For Script module - use require:

js
const contentNodeUtil = require('ContentNodeUtil');

Step 2 - Make use of ContentNodeUtil

js
// 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);