Using Search Widget Templates
ご覧のページは、お客様の利便性のために一部機械翻訳されています。また、ドキュメントは頻繁に更新が加えられており、翻訳は未完成の部分が含まれることをご了承ください。最新情報は都度公開されておりますため、必ず英語版をご参照ください。翻訳に問題がある場合は、 こちら までご連絡ください。

検索結果ウィジェットテンプレートリファレンス

検索結果ウィジェット テンプレートを作成しながら、FreeMarker テンプレート エディターで事前に入力された変数にアクセスできます。 エディターにリストされている変数は何が可能かを示していますが、検索結果ウィジェット テンプレートのコンテキストではさらに多くの変数を使用できます。 ご使用のバージョンに固有のソース コードには、テンプレート コンテキストに挿入される変数の正式なリストが含まれています。

これらの Java クラスは、検索結果ウィジェットに使用可能なテンプレート変数を提供します。 https://github.com/liferay/liferay-portal/tree/7.4.3.132-ga132を検索すると見つかります:

  • SearchContainer: このクラスのゲッターの一部は、検索結果ウィジェット テンプレートの変数です。 利用可能なものについては、以下のリストを参照してください。
  • SearchResultsPortletDisplayContext: このクラスのすべてのゲッターは、検索結果ウィジェット テンプレートに変数を提供します (例: getDisplayStyleGroupId())。
  • SearchResultSummaryDisplayContext: このクラスのすべてのゲッターは、検索結果ウィジェット テンプレートに変数を提供します (例: getDisplayStyleGroupId())。

現在利用可能な変数のわかりやすいリストを以下に示します。

エディターフィールド名説明Javaの戻り値の型使用例
ドキュメントとメディア検索結果エントリのコレクション。 各エントリで使用できる内容を確認するには、「検索結果エントリ フィールド」を参照してください。List< SearchResultSummaryDisplayContext>
検索コンテナ検索コンテナーを使用して、検索結果とそのプロパティを含むグリッドを構築できます。SearchContainer例については、 検索コンテナの使用 を参照してください。
現在の結果ページ番号int${searchContainer.getCur()}
現在のページ番号のパラメータ名String${searchContainer.getCurParam()}
デルタ、つまりページごとに表示するエントリの数int${searchContainer.getDelta()}
デルタパラメータ名String${searchContainer.getDeltaParam()}
表示する最後の結果のインデックスint${searchContainer.getEnd()}
検索コンテナインスタンスのIDString${searchContainer.getId(request, nameSpace)}
ページ区切りのページURLPortletURL${searchContainer.getIteratorURL()}
列の並べ替えString${searchContainer.getOrderByCol()}
ソート列パラメータ名String${searchContainer.getOrderByColParam() }
列の順序タイプ(昇順または降順)String${searchContainer.getOrderByType()}
並べ替えの基準となるパラメータString${searchContainer.getOrderByTypeParam()}
ポートレットリクエストPortletRequest${searchContainer.getPortletRequest()}
表示する最後のヒットのインデックスint${searchContainer.getResultEnd()}
結果文書のリストList<Document>${searchContainer.getResults()}
最初からスキップするヒット数int${searchContainer.getStart()}
ヒット数合計int${searchContainer.getTotal()}
成果があるかどうかboolean${searchContainer.hasResults()}
ユーザーがページごとに表示されるアイテムの数を選択できるかどうかboolean${searchContainer.isDeltaConfigurable()}
ホバー効果を使用するかどうかboolean${searchContainer.isHover()}
検索結果ディスプレイコンテキスト現在の検索とウィジェットの設定に関する情報SearchResultsDisplayContext
ウィジェットテンプレートのサイトIDlong${searchResultsPortletDisplayContext.getDisplayStyleGroupId()}
取得した検索エンジンの文書List<Document>${searchResultsPortletDisplayContext.getDocuments()}
現在の検索キーワードString${searchResultsPortletDisplayContext.getKeywords()}
検索コンテナSearchContainer${searchResultsPortletDisplayContext.getSearchContainer()}
検索結果ポートレットインスタンスの構成SearchResultsPortletInstanceConfiguration${searchResultsPortletDisplayContext.getSearchResultsPortletInstanceConfiguration()}
検索エンジン ドキュメントの検索結果の概要コンテキスト。 検索結果入力フィールドを参照してください。SearchResultSummaryDisplayContext${searchResultsPortletDisplayContext.getSearchResultSummaryDisplayContext(document)}
検索結果の概要コンテキスト。 検索結果入力フィールドを参照してください。List<SearchResultSummaryDisplayContext>${searchResultsPortletDisplayContext.getSearchResultSummaryDisplayContexts()}
ヒット数合計int${searchResultsPortletDisplayContext.getTotalHits()}
ウィジェットが表示されているかどうかboolean${searchResultsPortletDisplayContext.isRenderNothing()}
ウィジェット設定で空の結果メッセージの表示を有効にするかどうかboolean${searchResultsPortletDisplayContext.isShowEmptyResultMessage()}
設定でページ区切りを有効にするかどうかboolean${searchResultsPortletDisplayContext.isShowPagination()}

検索結果ごとに使用できる変数があります。 いくつかはテンプレート エディターに表示されますが、他にも以下のものがあります。

エディターフィールド名説明タイプ使用例
アセットのユーザー ID。 エントリがユーザーの場合、値はそのユーザーの ID になります。long${entry.getAssetEntryUserId()}
アセットのダウンロードURLString${entry.getAssetRendererURLDownload()}
エントリのモデルクラス名String${entry.getClassName()}
エントリのバッキングモデルの主キーlong${entry.getClassPK()}
コンテントハイライト表示された検索結果の概要コンテンツString${entry.getContent()}
制作日エントリ作成日String${entry.getCreationDateString()}
作成者のユーザー名エントリー作成者のフルネームString${entry.getCreatorUserName()}
作成者のユーザー写真エントリー作成者のポートレート/アバターのURLString${entry.getCreatorUserPortraitURLString()}
資産カテゴリIDリクエストパラメータ名String${entry.getFieldAssetCategoryIds()}
資産タグ名リクエストパラメータ名String${entry.getFieldAssetTagNames()}
タイトルハイライトされたタイトルString${entry.getHighlightedTitle()}
表現されるモデルクラス/アセットエントリタイプのCSSアイコンクラスString${entry.getIconId()}
現在の表示言語と異なる場合の要約言語IDString${entry.getLocaleLanguageId()}
要約言語IDが現在の表示言語と異なることを通知するテキストString${entry.getLocaleReminder()}
エントリによって表されるモデルクラスのラベルString${entry.getModelResource()}
変更者のユーザー名エントリの最終変更者のフルネームString${entry.getModifiedByUserName()}
変更者のユーザー写真最後の変更者のポートレート/アバターのURLString${entry.getModifiedByUserPortraitURLString()}
編集日エントリの最終更新日String${entry.getModifiedDateString()}
現在のテーマの画像ディレクトリのパスString${entry.getPathThemeImages()}
検索結果ポートレットインスタンスのポートレットURLPortletURL${entry.getPortletURL()}
公開日エントリーの公開日String${entry.getPublishedDateString()}
バックアップアセットエントリのサムネイルのURLString${entry.getThumbnailURLString()}
検索結果エントリの裏付け資産のタイトルString${entry.getTitle()}
バックアップアセットエントリを作成したユーザーのポートレート/アバターのURLString${entry.getUserPortraitURLString()}
検索結果エントリの表示URLString${entry.getViewURL()}
バックアップ資産エントリに資産カテゴリまたはタグがあるかどうかboolean${entry.isAssetCategoriesOrTagsVisible()}
アセットのダウンロードURLが利用可能かどうかboolean${entry.isAssetRendererURLDownloadVisible()}
要約コンテンツが利用可能かどうかboolean${entry.isContentVisible()}
作成日が利用可能かどうかboolean${entry.isCreationDateVisible()}
作成者の肖像が利用可能かどうかboolean${entry.isCreatorUserPortraitVisible()}
作成者の名前が利用可能かどうかboolean${entry.isCreatorVisible()}
ドキュメント表示モードが有効かどうかboolean${entry.isDocumentFormVisible()}
クラス名や主キーのないエントリのドキュメントフィールドが使用可能かどうかboolean${entry.isFieldsVisible()}
表現されたモデルクラス/アセットエントリタイプのCSSアイコンクラスが使用可能かどうかboolean${entry.isIconVisible()}
ロケールリマインダーテキストが利用可能かどうかboolean${entry.isLocaleReminderVisible()}
このエントリで表されるモデルクラスのラベルが使用可能かどうかboolean${entry.isModelResourceVisible()}
最後の修飾子の名前が使用可能かどうかboolean${entry.isModifiedByUserNameVisible()}
最後の修飾子のポートレートが利用可能かどうかboolean${entry.isModifiedByUserPortraitVisible()}
最終更新日が利用可能かどうかboolean${entry.isModifiedDateVisible()}
公開日が利用可能かどうかboolean${entry.isPublishedDateVisible()}
エラーのためエントリが利用できないかどうかboolean${entry.isTemporarilyUnavailable()}
アセットのサムネイルが利用可能かどうかboolean${entry.isThumbnailVisible()}
アセットエントリ作成者がポートレートを利用できるかどうかboolean${entry.isUserPortraitVisible()}

検索コンテナの使用

検索結果を表示するための検索コンテナの設定例を次に示します。

<@liferay_ui["search-container"] searchContainer=searchContainer>

   <@liferay_ui["search-container-results"] results=searchContainer.results>

      <@liferay_ui["search-container-row"]
         className="com.liferay.portal.kernel.search.Document"
         keyProperty="UID" modelVar="document"
      >

         <@liferay_ui["search-container-column-text"]
            href="" name="Title" value=document.get("localized_title_en_US")
         />
      </@>
   </@>

   <@liferay_ui["search-iterator"] />
</@>
<#assign localized_title_field="localized_title_${locale}"/>
<#assign localized_content_field="content_${locale}"/>

<@liferay_ui["search-container"] searchContainer=searchContainer>

   <@liferay_ui["search-container-results"] results=searchContainer.results>

      <@liferay_ui["search-container-row"]
         className="com.liferay.portal.kernel.search.Document"
         keyProperty="UID" modelVar="document"
      >
				<@liferay_ui["search-container-column-text"]
               href="" name="Title" value=document.get(localized_title_field)
            />

				<@liferay_ui["search-container-column-text"]
               href="" name="Content" value=document.get(localized_content_field)
            />

				<@liferay_ui["search-container-column-text"]
               href="" name="Class Name" value=document.get("entryClassName")
            />
      </@>
   </@>

   <@liferay_ui["search-iterator"] />
</@>

検索コンテナーには検索結果のグリッドが表示されます。