SilverStripe (3.6.2) 搜索返回资产文件夹内容

SilverStripe (3.6.2) Search returning assets folder contents

我以前没有在 SilverStripe 上启用搜索,但这似乎很容易。我已经按照其他 2 个启用了搜索的项目(虽然它们是 3.5 版本的项目,但不确定是否有所不同)的步骤以及 SilverStripe 网站上提供的教程进行操作,出于某种原因,我得到了资产我的搜索结果中的文件夹项目(即图像)。这似乎只有在我点击搜索但搜索字段中没有输入任何内容时才会发生。

任何时候搜索都不应返回任何资产项目,如果没有搜索查询,则应该有一条消息说没有输入任何内容。我注意到使用基本安装提供的默认 $SearchForm 设置可以得到我想要的结果,但对于我正在使用的表单却不是(它在其他 2 个 SilverStripe 网站上有效——我检查并确认)。

我不确定我错过了什么?我觉得一切都做得很好,我想使用我现在拥有的设置来给我更多的造型能力:

来自_config.php:

FulltextSearchable::enable();

来自我的 Header.ss 文件:

 <!-- 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 &quot;{$Query}&quot;</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 &quot;{$Title}&quot;">Read more about &quot;{$Title}&quot;...</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">&larr;</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">&rarr;</a>
                                <% end_if %>
                            </div>
                            <p>Page $Results.CurrentPage of $Results.TotalPages</p>
                        </div>
                    <% end_if %>
                </div>
            </div>
        </div>
    </div>
</div>

默认全文搜索会搜索array('SiteTree', 'File')

http://api.silverstripe.org/en/3.1/class-FulltextSearchable.html

我会尝试将您的 FulltextSearchable::enable(); 行更改为 FulltextSearchable::enable(array('SiteTree'));

我以前没有尝试过,不确定它是否有效。