Another newbie question ;
I want to give editor/authors the possibility to create project pages, where they can put in random content and also put a dedicated “Project detail component” that renders specifics about “a project”.
For this I’ve created a prototype page with a container on it.
/hst:hst/hst:configurations/myproject/hst:prototypepages:
jcr:primaryType: hst:pages
/project-detail-page:
jcr:primaryType: hst:component
jcr:mixinTypes: ['hst:prototypemeta']
hst:displayname: Project Detail Page
hst:referencecomponent: hst:abstractpages/base
/main:
jcr:primaryType: hst:component
hst:template: project-detail
/container:
jcr:primaryType: hst:containercomponent
hst:xtype: hst.vbox
I’ve also created a document, to store project related content.
@Node(jcrType="myproject:projectdocument")
public class ProjectDocument extends BaseDocument {...}
This content is stored under /content/documents/myproject/projects/{name}
I wanted the controller to retrieve the content bean, via the url matching(sitemap)
@ParametersInfo(type = FeaturedProjectInfo.class)
public class FeaturedProjectComponent extends BaseHstComponent {
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
super.doBeforeRender(request, response);
final HstRequestContext ctx = request.getRequestContext();
// Retrieve the document based on the URL
ProjectDocument document = (ProjectDocument) ctx.getContentBean();
When browsing to http://localhost:8080/site/projects/sampleproject, the ctx.getContentBean() renders null.
So I assume it doesn’t know how to get the content based on the request and I need configuration in the sitemap.
When I look in hst:workspace > hst:sitemap there is a projects node, which has the sampleproject node. But there is no “hst:relativecontentpath” (there also is no mapping like any or any.html - this is related to the fact that I’m using a prototype page and the mapping is generated in hst:workspace?)
When I try this:
ctx.getSiteContentBaseBean().getBean("projects/sampleproject") I do find the HippoDocument.
After some debugging it looks like I can’t have a relative path null. (HstRequestContextImpl.class)
private HippoBean getBeanForResolvedSiteMapItem(ResolvedSiteMapItem resolvedSiteMapItem) {
String base = this.getSiteContentBasePath();
String relPath = PathUtils.normalizePath(resolvedSiteMapItem.getRelativeContentPath());
if(relPath == null) {
log.debug(“Cannot return a content bean for relative path null for resolvedSitemapItem belonging to ‘{}’. Return null”, resolvedSiteMapItem.getHstSiteMapItem().getId());
return null;
} else {
return this.getHippoBean(base, relPath);
}
}
Not sure if I’m doing it the right way. I’m sure it can’t be the purpose that a cms editor starts messing in the cms/console.
Input appreciated
Thanks
Cheers
J