How to embed a widget on a Turbo page

You can embed Yandex.Market and Beru widgets on Turbo pages.

  1. How to place widget code
  2. How to add multiple widgets to a single page

How to place widget code

After you created your widget code in the constructor or manually:

  1. Make sure the widget doesn't use a product search by a request from an HTML element (the searchSelector parameter) or by an image from the img element (the searchImageSelector parameter). Turbo pages don't support these search methods.

  2. Embed the code with the widget parameters in the <![CDATA[]]> section inside the turbo:content element. Example:

    <rss ...>
      <channel>
        ...
        <item turbo="true">
          ...
          <turbo:content>
            <![CDATA[
              <!-- Text preceding the widget -->
              <script type="text/javascript">
                window.YaMarketAffiliate.createWidget({
                  containerId: "marketWidget",
                  ...  // Widget parameters
                });
              </script>
              <!-- Text after the widget -->
            ]]>
          </turbo:content>
        </item>
        ...
      </channel>
    </rss>

    Don't embed the Widget API connection code and HTML container for displaying the widget.

    For more information about creating Turbo pages, see the technical documentation for Turbo pages, The RSS feed markup section.

How to add multiple widgets to a single page

To place multiple widgets on the same page, embed each widget's code with its parameters (the script element) in the <![CDATA[]]> section inside the turbo:content element. Each widget must have its own value for the containerId parameter. Example:

<rss ...>
  <channel>
    ...
    <item turbo="true">
      ...
      <turbo:content>
        <![CDATA[
          <!-- Text preceding the first widget -->
          <script type="text/javascript">
            window.YaMarketAffiliate.createWidget({
              containerId: "marketWidget1",
              ...  // Parameters of the first widget
            });
          </script>
          <!-- Text inserted between the first and second widgets -->
          <script type="text/javascript">
            window.YaMarketAffiliate.createWidget({
              containerId: "marketWidget2",
              ...  // Parameters of the second widget
            });
          </script>
          <!-- Text after the second widget -->
        ]]>
      </turbo:content>
    </item>
    ...
  </channel>
</rss>

Turbo pages don't support the method described in the How to embed widgets on a site section (creating an array of objects with widget parameters and looping the YaMarketAffiliate.createWidget method call for these objects). One widget must correspond to one script element and vice versa.