Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Making content searchable
I have written a simple CMS application and I want the content of the pages to be searchable though the vanilla default search (everything from the same box)
How do I add own items to the search?
How do I add own items to the search?
Tagged:
0
Comments
- Make sure your content has fulltext indexes. You do this in the structure file by specifying an index type of 'fulltext' on the relevant columns. Look at Vanilla's structure file if you aren't sure about the correct syntax.
- Using the SQL object, build queries that will grab your content in a format that the search expects. Again, Vanilla does all of this in /applications/vanilla/models/class.vanillasearchmodel.php. Make sure all of your columns are selected in the same order that Vanilla does it or things will get mixed up. You will notice that there is a $this->SQL->Reset. Make sure you don't leave this out or you will some very strange errors.
- Hook into the search system in your application's hooks file. If you are doing this in a plugin then to it in the plugin (since the hooks file is just a plugin. Your event handler will look something like this (again, from Vanilla):
If you have just a simple, one table search then you can just put everything in your hooks file.So to summarize, look at the following files:
The directory:
applications/vanilla/models/class.vanillasearchmodel.php
has a function DiscussionSql() that accepts the columns to match against. I added
d.Tags
to
'd.Body, d.Name'
in the second argument. You are required to add whatever columns from the Discussions table you add to the match clause to the FULLTEXT index in the database.
This hardcoded solution probably isn't best practice and should be handled with a hook or a plugin as Todd describes above.