Is there a simple way to tell Silverstripe to not include the Forms folder under Assets in local site search results?
I am using version 3.0.5
Thanks!
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Is there a simple way to tell Silverstripe to not include the Forms folder under Assets in local site search results?
I am using version 3.0.5
Thanks!
I'm surprised no one has encountered this before. Perhaps I didn't explain what I'm trying to accomplish very clearly.
I have PDF files with the path: www.mydomainname.com/assets/Forms/FileName.pdf
What I want to do is stop the internal site search from showing anything inside the Forms folder in the search results.
Is anyone able (and willing) to give me specific instructions on how to achieve this?
Thanks!
Hey goodness,
There is a 'ShowInSearch' boolean field on the File class already, but it's not surfaced in the Files section of the CMS at the moment. You have two options:
Option 1: Follow either of the instructions here to disable searching all File objects (or, using the SQL, you could disable searching for only a sub-set of files (by finding the 'ID' of the Forms folder as you mention below, and amending the SQL query).
Option 2: Add a 'FileExtension' class which surfaces that checkbox, so that for individual files, you can use the CMS to change whether or not you want that file shown in search. That extension class would look something like this (untested, use at your risk!): http://sspaste.com/paste/show/52f163516d33b.
For what it's worth, the code that actually performs the search is specific to the database engine in use. I presume you're using MySQL, so the code that searches by default is here: https://github.com/silverstripe/silverstripe-framework/blob/3.0/model/MySQLDatabase.php#L842