Answers.Body: <p>A while since you asked, so in case you haven't figured it out yet, here goes:</p>
  
  <p>To attach to a plugin hook, you need to create your own plugin. So in your plugins folder, add a new folder called <code>SearchPlusItemMapping</code> or whatever you want to call your plugin. In that folder you'll need to create a php file called <code>SearchPlusItemMappingPlugin</code> (change whatever comes before <code>Plugin</code> if you gave your plugin a different name. In this file, add the following lines:
      namespace Craft;</p>
  
  <pre><code>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(){}
  }
  </code></pre>
  
  <p>And then at the bottom you add your function.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-27T10:00:53.140Z
Answers.LastActivityDate: 2017-09-27T10:00:53.140Z
Answers.UserDisplayName: peirix
Body: <p>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?</p>
  
  <p>In a nutshell what I'm wanting to do is to modify the standard Search Plus mapping to include the <code>section handle</code>. I think this is the function I need:</p>
  
  <pre><code>public function searchPlus_alterBasicItemMapping($mappedData, $orginalElement)
  {
      $mappedData["sectionHandle"] = $section-&gt;handle;
      return $mappedData;
  }
  </code></pre>
  
  <p>But I have no idea where to put it and how to get it to talk to the plugin...</p>
  
Tags: <plugin-development><plugin-searchplus>
Title: Search Plus Custom Mapping
ThreadText: # Search Plus Custom Mapping
  
  (Asked by: username_0 on 2017-06-28)
  
  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...
  
  **Tags:** plugin-development, plugin-searchplus
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-27. Score: 2 | Accepted answer
  
  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.
  
  
  ---
  
  