Strict Standards: Redefining already defined constructor for class Object in /home/dizz/cake_1.2.5/cake/libs/object.php on line 63

Strict Standards: Non-static method Configure::getInstance() should not be called statically in /home/dizz/cake_1.2.5/cake/bootstrap.php on line 47
Croogo Full Text Search |

Croogo Full Text Search



Croogo currently doesn't have full text search but with this action you can add full text capabilities to your Croogo installation. This is not guaranteed to work after Croogo 1.1, and hopefully full text search is implemented into the core. Currently this implementation allows you to search blog posts.


  • Croogo 1.1
  • MySQL


The search action must go into the nodes controller. You will need to make a search form that's url points to the nodes controller and the search method. In this implementation I am using the "GET" method and it's reflected in the search action. In your search.ctp view you can use the CakePHP text helper to highlight the search term and display an excerpt instead of the full post. Below is an example:

<p><?php echo $text->highlight($text->excerpt(strip_tags($this->element('node_body', array('node' => $node))), $q, 200, '...'), $q); ?></p>


function search () {
// Import sanitize library
App::import('Core', array('Sanitize'));

$query = mysql_escape_string(Sanitize::html($this->params['url']['q']));

$this->paginate['Node']['order'] = ' DESC';
$this->paginate['Node']['limit'] = Configure::read('Reading.nodes_per_page');
$this->paginate['Node']['conditions'] = array(
'Node.type' => 'blog',
'Node.status' => 1,
"MATCH(Node.title, Node.body) AGAINST('{$query}' IN BOOLEAN MODE)"
$this->paginate['Node']['contain'] = array(
'Term' => array('Vocabulary')

$this->Node->recursive = 0;
$this->set('nodes', $this->paginate());
$this->set('q', $query);
$this->set('title', "Search results for {$query}");

If you have any questions or comments drop me a line below and I will try to get back to you as soon as possible.

Last Updated: December 9th 2009, 6:26am

Download: Croogo Full Text Search

1 Comment

Strompreise said on January 9th 2012, 2:57pm
Hi there, just wanted to mention, I loved this blog post. It was practical. Keep on posting!
Add New Comment