21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1466 Views |
-
Search results returning javascript file in assets

13 February 2010 at 12:29am Last edited: 13 February 2010 12:55am
If you enter the search term 'cms' into the search form on our site it returns cmsmain.js in the assets folder as a result. My understanding of the search is that it only searches the database sitetree table, so I am very surprised to see an item from the assets folder there.
The site uses Silverstripe 2.3.3
How do I stop these javascript files showing (which Silverstripe puts in the assets folder)?
-
Re: Search results returning javascript file in assets

13 February 2010 at 5:26am
I don't get this in the 2.4 beta version (the only site I have an inline search one, so all I can test).
Have you tried updating to the latest 2.3.x release?
Mo
-
Re: Search results returning javascript file in assets

15 February 2010 at 1:47am
I have this problem too, and I'm using 2.4.
It is displaying other files from the assets folder too, .flv .html etc. It appears to already ignore images though.
How can we control what the search engine looks in?
-
Re: Search results returning javascript file in assets

15 February 2010 at 11:06pm
I've been doing some more digging since posting this request. I found that there is a static set in /sapphire/search/SearchForm.php
protected $classesToSearch = array("SiteTree", "File"); So it looks like it searches the Files table as well as the SiteTree.
In the same file there is also the following method:
/**
* Set the classes to search.
* Currently you can only choose from "SiteTree" and "File", but a future version might improve this.
*/
function classesToSearch(array $classes)So it looks like having created a new SearchForm object you could call this method in your search method (probably in Page.php) and remove Files - by just passing in SiteTree..
In this method there are also arrays set up of which columns to search. However there doesn't seem to be a way to change this other than hacking it.
I cannot find any useful documentation on how the search works, the tutorial is a start, but more is needed.
Searching the File table is not very useful as it only holds the file names/paths. What would be useful is to be able to search the assets if they are something like pdf files.
I have come to the conclusion that SilverStripe's search is not one of it's strengths and I would really like to see it improved considerably.
-
Re: Search results returning javascript file in assets

10 August 2010 at 8:17am
Was searching on how to stop the searching of the assets, seems you can just add this in your Page.php -> function results()
$form->classesToSearch(array('SiteTree'));
before
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);just for future reference for others
| 1466 Views | ||
|
Page:
1
|
Go to Top |



