legacy-knowledge-base
公開されました Jun. 30, 2025

ウェブコンテンツ記事で設定された表示ページテンプレートを取得する

written-by

Jose Bodega

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • 目標は、LiferayのAPIを通して、ウェブコンテンツ記事が表示ページテンプレートに関連付けられたときに、それを取得することです。

環境

  • Liferay DXP 7.4+

解像度

  • 例としてGroovyスクリプトを添付します。このスクリプトを通して、特定のウェブコンテンツに関連する表示ページテンプレートを取得します。 以下のAPIサービスのみを使用する:

    • 雑誌記事
    • AssetDisplayPageEntry -> この後者は、あらゆるタイプのアセット、特にウェブコンテンツに関連するページテンプレートへのアクセスを提供するサービスである。
  • import com.liferay.journal.service.JournalArticleLocalServiceUtil
    import com.liferay.asset.display.page.service.AssetDisplayPageEntryLocalServiceUtil
    import com.liferay.journal.model.JournalArticle
    import com.liferay.asset.display.page.model.AssetDisplayPageEntry
    JournalArticle journal=JournalArticleLocalServiceUtil.fetchArticle(X)
    classnameid = com.liferay.portal.kernel.service.ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class)
    AssetDisplayPageEntry aseetEntry=AssetDisplayPageEntryLocalServiceUtil.fetchAssetDisplayPageEntry(journal.getGroupId(),classnameid ,journal.getResourcePrimKey())
    out.println(aseetEntry.getLayoutPageTemplateEntryId());
  • 特に:
    • 最初の部分では、通常のウェブコンテンツはそのIDによって検索される。
    • AssetDisplayPageEntryLocalServiceUtil APIを使用して、前のJournalで取得したパラメータを使用すると、LayoutPageTemplateEntryIdフィールドを含む関連するAssetDisplayPageEntryモデルを取得できます。 このフィールドには、アセットに関連付けられたページテンプレートの識別子、またはアセットにテンプレートがない場合は0が格納されます。

did-this-article-resolve-your-issue

legacy-knowledge-base