legacy-knowledge-base
公開されました Jul. 2, 2025

埋め込み型ポートレットでポジションタグリブを使う

written-by

Antonio Ortega

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プラットフォームを使用する際に、4つの異なるポジションタグリブを使用する方法を説明します。 タグリブは以下の4つです: BodyBottomTag, BodyTopTag, HtmlBottomTag and HtmlTopTag...。

これらのタグリブは、その中に含まれるコードを、DOM(Document Object Model)内の指定された領域の上部または下部に配置します。 また、テーマ内にポートレットを埋め込むこともできます。 本記事では、これらのポジションタグリブの使用方法について、情報および使用例を提供します。

解決策

ポートレットの中に位置タグリブの1つを含めると、ポートレットが埋め込まれているかいないかで、デフォルトの動作が少し違ってきます。

  • ポートレットが埋め込まれていない

    ポートレット 埋め込まれていない場合、taglib は上部または下部にコードを含むことになります。

  • ポートレットが埋め込まれている

    ポートレット 埋め込まれている場合、taglib はコードをインラインで含めることになります。 つまり、ポートレットが埋め込まれている位置と同じ位置に。

埋め込みポートレットがこのように機能するのは、JavaScriptを読み込んだ後に追従するためで、埋め込みポートレットのレンダリング時のパフォーマンス問題を回避するのに役立ちます。

デフォルトの動作として、コードを上部または下部に表示するpositionタグリブを持つポートレットを埋め込みたい場合、そのタグリブの属性position(値 auto )を利用する必要があります。 以下は、埋め込みポートレットのコードの一部の例です:

アトリビュート・ポジションを使用せずに

<liferay-util:html-bottom>
    <script>
        console.log('This log will be executed inline.');
    </script>
</liferay-util:html-bottom>

アトリビュート・ポジションを使用する:

<liferay-util:html-bottom position="auto">
    <script>
        console.log('This log will be executed at the bottom.');
    </script>
</liferay-util:html-bottom>

did-this-article-resolve-your-issue

legacy-knowledge-base