## Recommendations A wrapper class available in twig that can retrieve a list of objects or teasers using one of several available modes. ### Configuration The extension is configured inside your `designs.cnd.yml` file in `app/config/extensions`. ``` # Enable selected designs modules modules: recommendations: true # Optional configuration for specific uses. Key 'default' is used if not given. # This is the default config, if nothing is specified recommendations: default: mode: relationlist-global ``` ### Use Inside your templates, a `Recommendations` object is available. It has two methods: * **getItems** Returns a list of objects (e.x.: Bolt records or Kraken objects). * **getTeasers** Returns a list of generated teaser objects as given by `cnd/basics` teaser generators. Function Parameters are: * **record** The current page's record. * **options** An array of options to use. Everything is optional. The option `config` specifies the recommendation configuration to use for this list. The default is `default`. ``` {% set options = { teaserImageSize: 'teaser_landscape', config: 'myrecolist' } %} {% set teasers = Recommendations.getTeasers(record, options) %} ``` ### Modes The following modes are available #### RelatedContent `relatedcontent` Return objects by similarity of their taxonomy. (See `cnd/related-content` for configuration options). If you specify a `config_contenttype` and `field` parameter in your module configuration, you can use fixed items from a RelationList field in a singleton contenttype, similar to the RelationListGlobal module. (See `cnd/relationlist` for field configuration) Options: * **contenttypes** array of allowed contenttypes for search * **taxonomies** array of taxonomies and wheights * **length** number of items in result * **config_contenttype** contenttype of singleton to use for fixed records * **field** name of field of type relationlist in singleton for fixed records ``` recommendations: myrecolist: mode: relatedcontent config_contenttypes: configurations field: recommendations length: 4 ``` #### RelationlistGlobal `relationlist-global` Return manually selected objects from a global contenttype's Relationlist field and fill up with the RelationFill class. (See `cnd/relationlist`) Options: * **contenttype** name of the global contenttype. (Default: `configurations`) * **field** name of relationlist field in global contenttype. (Default: `teasers`) * **length** number of items in result #### RelationlistLocal `relationlist-local` Return manually selected objects from current record's Relationlist field and fill up with the RelationFill class. (See `cnd/relationlist`) Options: * **field** name of relationlist field in current record. (Default: `teasers`) * **length** number of items in result #### RelationlistManual `relationlist-manual` Return a list of objects from the RelationFill class with a manually specified pool. (See `cnd/relationlist`) Options: * **pool** name of the relationlist pool to use. * **length** number of items in result