1

I've not managed to find any complete example of a custom mapping plugin for Search Plus—I'm wondering if anyone could steer me in the right direction?

In a nutshell what I'm wanting to do is to modify the standard Search Plus mapping to include the section handle. I think this is the function I need:

public function searchPlus_alterBasicItemMapping($mappedData, $orginalElement)
{
    $mappedData["sectionHandle"] = $section->handle;
    return $mappedData;
}

But I have no idea where to put it and how to get it to talk to the plugin...

2

A while since you asked, so in case you haven't figured it out yet, here goes:

To attach to a plugin hook, you need to create your own plugin. So in your plugins folder, add a new folder called SearchPlusItemMapping or whatever you want to call your plugin. In that folder you'll need to create a php file called SearchPlusItemMappingPlugin (change whatever comes before Plugin if you gave your plugin a different name. In this file, add the following lines: namespace Craft;

class SearchPlusMappingPlugin extends BasePlugin
{
    public function getName()
    {
        return Craft::t('Search Plus Item Mapping');
    }

    public function getVersion()
    {
        return '1.0';
    }

    public function getDeveloper()
    {
        return 'Your Name';
    }

    public function getDeveloperUrl()
    {
        return 'https://somesite.com';
    }

    public function searchPlus_alterBasicItemMapping(){}
}

And then at the bottom you add your function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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