How do I find specific resources?
Use ResourceLocatorUtil and its many dedicated methods.
Published: 2022-07-22 | Updated: 2024-09-26
ResourceLocatorUtil has dedicated methods to get hold of different resources in Sitevision such as the Image Repository, the File Repository or the Trashcan. It also has methods to get a specific node by identifier, path or URL.
Step 1 - Get an instance of ResourceLocatorUtil
For WebApp/RESTApp - use import:
js
import resourceLocatorUtil from '@sitevision/api/server/ResourceLocatorUtil';
For Script module - use require:
js
const resourceLocatorUtil = require('ResourceLocatorUtil');
Step 2 - Make use of the methods in ResourceLocatorUtil
js
// Get hold of the global File Repository
const fileRepository = resourceLocatorUtil.getFileRepository();
// Get hold of a specific node by its identifier
const article = resourceLocatorUtil.getNodeByIdentifier('5.196f6965181f1df20652f94');
// Get hold of the local Image Repository of a specific article
const localImageRepository = resourceLocatorUtil.getLocalImageRepository(article);
// Get hold of the Site Page
const sitePage = resourceLocatorUtil.getSitePage();
// Get hold of the Trashcan
const trashcan = resourceLocatorUtil.getTrashcan();
// Get hold of the Template Repository
const templateRepository = resourceLocatorUtil.getTemplateRepository();
// ...