Manual initialization

Out of the box, the Search & Merchandising plugin will automatically start looking for an input, output and start the initialization.

If you need more control, for example if you want to initialize on your own terms, you can achieve this with some additional configuration.


Disable auto-initialization

<script>
  window["twn-starter-config"] = window["twn-starter-config"] || {};
  window["twn-starter-config"].auto = false;
</script>

Manually initialize

<script>
  window.addEventListener('twn.starter.ready', function () {
    let listerPage = tweakwiseListerPage({
      output: '#tweakwise-output',
      cid: '1', // Enter your category ID here
      query: null // Enter a search term in case of a search results page
    });
    
    listerPage.setOpen(true);
    listerPage.setOpen(false);
    listerPage.setQuery('another search term');
    listerPage.destroy();
  });
</script>

The tweakwiseListerPage method will use the configuration from Plugin Studio. It exposes some basic methods to interact with the plugin:

  • setOpen: open/close the search results
  • setQuery: provide or reset a searchterm
  • destroy: destroy instance, for example to recreate a new one

Note: In the snippet above the CID needs to be replaced with the ID of the category you want to show. This ID should be known in Tweakwise, as provided through the feed or Backend API.