After the search input html tag on line 53, add the following code just below. This is the html for the content filter:
<?php echo JText::_( 'Filter by Content' ); // wpg - adding a content filter?>:
<input type="text" name="search_content" id="search_content" value="<?php echo $lists['search_content'];?>" class="text_area" onchange="document.adminForm.submit();" title="<?php echo JText::_( 'Filter by content' );?>"/>
then on the Reset button code at line 60(ish), add the following to the onclick event to reset the content search box when the reset button is pressed:
document.getElementById('search_content').value='';
That is all the code we need to add to this script. Now we just need a few more lines of code in our controller and we are all set.
Finishing up with controller.php
Now that we have added the html for our content filter we need to add the code that will actually perform the search. Here we go.
Within the viewContent function, go to about line 65 (just below where the $search variable is set and add the following. This will grab the string or phrase we are searching on.
$search_content = $mainframe->getUserStateFromRequest('articleelement.search_content', 'search_content', '', 'string');
$search_content = JString::strtolower($search_content);
Now we need to modify the query to the database. So at about line 125 (below where the keyword filter is set) add the following lines. This will check to see if the word or phrase is in the introtext or fulltext of the articles.
if ($search_content) {
$where[] = 'LOWER( c.introtext ) LIKE '.$db->Quote( '%'.$db->getEscaped(
$search_content, true ).'%', false ).
' OR LOWER( c.fulltext ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search_content, true ).'%', false );
}
The content search should now work but we want to add one more line of code so that when we do a filter, our filter request is saved in the text box. So at the end of the function, just before the ContentView::showContent function call, we need the following line of code (at about line 205):
$lists['search_content'] = $search_content;