Out of the box, SilverStripe 2.4 with the Data Object Manager supports search results for files added with the data object manager.
The template code below shows the name of the file being searched for but NOT the description:
<h3><a class="searchResultHeader" href="$Link">$Title</a></h3>
<p>$Description</p>
Here is my PHP code:
<?php
class FileItem extends DataObject
{
static $db = array (
'Text' => 'Varchar',
'Description' => 'Text'
);
static $has_one = array(
'Attachment' => 'File',
'Page'=>'Page'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Text','File Title'),
new TextareaField('Description','Description for Search Results'),
new FileIFrameField('Attachment','File')
);
}
}
?>
How can I get the Description to show in search results?