Multiple Page Mappings in a Single SiteMap Item
Overview
You can configure a single sitemap item to render different document types using distinct page components. This approach is useful when you have a folder, such as common, that contains documents of various types and you want each type to use a specific page layout.
Example Scenario
Suppose your content structure includes a common folder with mixed document types, such as simpledocument and advanceddocument:
/content: /documents: /myproject: /common: /about-us: jcr:primaryType: myproject:simpledocument /address: jcr:primaryType: myproject:simpledocument /contact-us: jcr:primaryType: myproject:advanceddocument
In this scenario, you may want to render advanceddocument and simpledocument types with different page layouts. For example, a simpledocument might use left, middle, and right components, while an advanceddocument uses only a middle component. Each document type should be associated with a different hst:componentconfiguration.
Approaches
To achieve this, you have several options:
- Group documents by type in separate subfolders (e.g.,
common/simple,common/advanced). - Use a SitemapItem Handler.
- Configure multiple explicit component configuration IDs per document type on a single sitemap item.
This page explains the third approach.
Configuration
You can assign multiple explicit component configurations to a single sitemap item by mapping document types to specific page components. The following example shows how to configure this in your hst:sitemap:
/hst:sitemap: jcr:primaryType: hst:sitemap /common: jcr:primaryType: hst:sitemapitem /**.html: jcr:primaryType: hst:sitemapitem hst:relativecontentpath: common/$[1] hst:componentconfigurationid: hst:pages/defaultpage hst:componentconfigurationmappingnames = ['myproject:simpledocument', 'myproject:advanceddocument'] hst:componentconfigurationmappingvalues = ['hst:pages/simplepage', 'hst:pages/advancedpage']
hst:componentconfigurationmappingnamesandhst:componentconfigurationmappingvaluesare multi-valued properties.- Both properties must have the same number of values.
- Each entry in
mappingnamescorresponds by index to an entry inmappingvalues.
Behavior
- If the document at the resolved
relativecontentpathis of typemyproject:advanceddocument, the page renders withhst:pages/advancedpage. - If the document is of type
myproject:simpledocument, the page renders withhst:pages/simplepage. - If the document is of any other type, the page renders with the default
hst:componentconfigurationid(hst:pages/defaultpagein this example).
This configuration allows you to store documents of any type directly under the common folder and render each type with its own page component. You do not need to create additional nested sitemap items or type-specific subfolders.
Note: The mapping does not consider sub-types. For example, if you have a
myproject:veryadvanceddocumentthat extendsmyproject:advanceddocument, it will be rendered usinghst:pages/defaultpagerather thanhst:pages/advancedpage.