Out of the box, Tweakwise JS will start looking for an input, output and start initializing the plugin.
If you need more control, for example if you want to initialize on your own terms, this can be achieved with some config:
- Set the
auto
initialization tofalse
- Execute
tweakwiseListerPage
<script>
window["twn-starter-config"] = window["twn-starter-config"] || {};
window["twn-starter-config"].auto = false;
</script>
const config = {
output: '#tweakwise-output',
cid: 'CID',
query: null // or 'Searchterm'
};
const { setOpen, setQuery, destroy } = tweakwiseListerPage(config);
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.