以前はSilverStripeでの検索は有効にしていませんが、かなり簡単です。私は、SilverStripeのサイトで提供されているチュートリアルだけでなく、検索が有効になっている2つのプロジェクト(3.5バージョンのプロジェクトですが、違いがあるかどうかはわかりませんが)の手順を実行しました。何らかの理由で、検索結果のフォルダ項目(画像など)これは、クリックして検索すると、検索フィールドに何も入力されていない場合にのみ発生します。SilverStripe(3.6.2)返品資産フォルダの内容を検索する
検索のために随時返されるアセットアイテムはありません。検索クエリがない場合、何も入力されなかったというメッセージが表示されます。私は、基本的なインストールで提供されるデフォルトの$ SearchFormセットアップを使用すると、私が使用しているフォーム(2つの他のSilverStripeサイトで動作します - 私は確認して確認しました)では望みの結果を得られないことに気付きました。
私には何が欠けているのですか?すべてが正しく行われているような気がして、私は私に多くのスタイリング能力与えるために私が今持っている設定を使用したい:私のHeader.ssファイルから
FulltextSearchable::enable();
:_config.phpから
を
<!-- SEARCH BAR -->
<form class="navbar-form navbar-left nav-right-left search-form" id="SearchForm_SearchForm" action="/home/SearchForm" method="get" enctype="application/x-www-form-urlencoded">
<fieldset style="font-size: 0;">
<div class="field text nolabel search-holder">
<input name="Search" placeholder="Search" class="form-control search-field text nolabel active search-box" />
</div>
<div class="ja-search-box">
<button class="icon search-button smiths-search-btn" type="submit"><i class="glyphicon glyphicon-search pull-right"></i></button>
</div>
</fieldset>
</form>
検索結果ページ:
<div class="main" role="main">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div id="Content" class="searchResults">
<h1 class="brand-red">$Title</h1>
<% if $Query %>
<p class="searchQuery">You searched for "{$Query}"</p>
<% end_if %>
<% if $Results %>
<ul id="SearchResults">
<% loop $Results %>
<li>
<h4>
<a href="$Link">
<% if $MenuTitle %>
$MenuTitle
<% else %>
$Title
<% end_if %>
</a>
</h4>
<% if $Content %>
<p>$Content.LimitWordCountXML</p>
<% end_if %>
<a class="readMoreLink" href="$Link" title="Read more about "{$Title}"">Read more about "{$Title}"...</a>
</li>
<% end_loop %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<% end_if %>
<% if $Results.MoreThanOnePage %>
<div id="PageNumbers">
<div class="pagination">
<% if $Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page">←</a>
<% end_if %>
<span>
<% loop $Results.Pages %>
<% if $CurrentBool %>
$PageNum
<% else %>
<a href="$Link" title="View page number $PageNum" class="go-to-page">$PageNum</a>
<% end_if %>
<% end_loop %>
</span>
<% if $Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page">→</a>
<% end_if %>
</div>
<p>Page $Results.CurrentPage of $Results.TotalPages</p>
</div>
<% end_if %>
</div>
</div>
</div>
</div>
</div>
Ah、ok。私はそれを試して、それはトリックを行ったように見えます。ありがとう! –