alkacon / opencms-core

The Java open source content management system by Alkacon Software
http://www.opencms.org
GNU Lesser General Public License v2.1
525 stars 576 forks source link

Resource type for detail pages #769

Closed AnnJul closed 1 year ago

AnnJul commented 1 year ago

While creating the link for a detail page (CmsDefaultDetailPageHandler.java), the resource type of the resource is not read from the resource itself but from the parent folder (defined in the module config). If more than one resource type is in the same content folder, the link creation fails, because the latest entry in the config overrides the other.

Example: Resource types in module config

<ResourceType>
      <TypeName><![CDATA[announcement]]></TypeName>
      <Disabled><![CDATA[false]]></Disabled>
      <Folder>
        <Name><![CDATA[support]]></Name>
      </Folder>
      <NamePattern><![CDATA[announcement_%(number).xml]]></NamePattern>
      <ElementView/>
</ResourceType>
<ResourceType>
      <TypeName><![CDATA[faq]]></TypeName>
      <Disabled><![CDATA[false]]></Disabled>
      <Folder>
        <Name><![CDATA[support]]></Name>
      </Folder>
      <NamePattern><![CDATA[faq_%(number).xml]]></NamePattern>
      <ElementView/>
</ResourceType>

JSP for announcement entry with a link to its detail page: <cms:link>${content.filename}</cms:link> --> filename: /support/announcement_00001.xml

public String getDetailPage(
        CmsADEManager manager,
        CmsObject cms,
        String contentRootPath,
        String originPath,
        String targetDetailPage) {

        boolean online = cms.getRequestContext().getCurrentProject().isOnlineProject();
        String resType = manager.getParentFolderType(online, contentRootPath);
...

CmsADEManager.getParentFolderType(true, '/.content/support/') --> faq (not announcement) --> no detail page link created

gWestenberger commented 1 year ago

Implemented in master branch.