1792 Posts in 588 Topics by 560 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 342 Views |
-
Customize search to omit assets folder

17 January 2012 at 6:53am
Hello,
I would like my search results to not show anything from the "assets" folder. How can I keep that folder out of the search results.
Here's my page_results.ss file:
<div class="viewport results-page">
<div class="content clearfix" style="padding:40px;">
<h1>Search Results</h1>
<% if Results %>
<ul id="SearchResults">
<% control Results %>
<li>
<% if MenuTitle %>
<h3><a class="searchResultHeader" href="$Link">$MenuTitle</a></h3>
<% else %>
<h3><a class="searchResultHeader" href="$Link">$Title</a></h3>
<% end_if %>
<% if Content %>
$Content.FirstParagraph(NoHTML)
<% end_if %>
<a class="readMoreLink" href="$Link" title="Read more about "{$Title}"">Read more about "{$Title}"...</a>
</li>
<% end_control %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<% end_if %><% if Results.MoreThanOnePage %>
<div id="PageNumbers">
<% if Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page">Next</a>
<% end_if %>
<% if Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
<% end_if %>
<span>
<% control Results.SummaryPagination(5) %>
<% if CurrentBool %>
$PageNum
<% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
</span></div>
<% end_if %>
</div>
</div>Thank You,
Alex -
Re: Customize search to omit assets folder

18 January 2012 at 3:27am
function results($data, $form, $request) {
$form->classesToSearch(array('Page', 'SiteTree'));
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => _t('SearchForm.SearchResults', 'Search Results')
);
return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
}Above is my overloaded "results" method.
You can set the classesToSearch on your form in your form action. The above will only search in the Page and SiteTree tables.
Hope that helps.
-
Re: Customize search to omit assets folder

15 February 2012 at 9:57am
Thanks swaiba, that's a better solution.
| 342 Views | ||
|
Page:
1
|
Go to Top |


