4

After many months, I've had to come back to a component that was well under way, which I thought was automatically indexing the data I was saving as it was saved. As I'm re-familiarizing myself with what code was underway, I've found that the automatic indexing isn't happening (anymore). I cannot, for the life of me, find anywhere that the indexing method is firing, nor can I find anything online that explains how to make that happen.

Running the CLI indexer does perform the indexing, so I know that the code works - I just can't figure out what in my component has gone missing (or perhaps was never implemented) that fires it automatically. I've studied Creating a Smart Search Plugin, and while it describes the methods and events to use, it doesn't explain or give and example of implementing it in the model.

Scouring the core Joomla code hasn't been much help because of the way all these events and methods are stored/named/inherited and then dynamically constructed to execute.

When I use the model ->save(), should I be loading/triggering something, or is there something in the model itself that I've forgotten or is missing?

1 Answer 1

1

In order to support SmartSearch, you need to write a finder plugin for your component. You may want to use plugins/finder/content/content.php as an example. The minimal skeleton is

class PlgFinderYourcomponent extends FinderIndexerAdapter
{
    /**
     * Method to index an item.
     *
     * @param   FinderIndexerResult $item The item to index as a FinderIndexerResult object.
     *
     * @return  boolean  True on success.
     *
     * @since   2.5
     * @throws  Exception on database error.
     */
    protected function index(FinderIndexerResult $item)
    {
        // ...
    }

    /**
     * Method to setup the adapter before indexing.
     *
     * @return  boolean  True on success, false on failure.
     *
     * @since   2.5
     * @throws  Exception on database error.
     */
    protected function setup()
    {
        // ...
    }
}

You might want to implement the onFinder...() methods, too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.