FastComments.com Blog

Wed Feb 12 2020
...

Using FastComments in Multiple Places On The Same Page

FastComments is adaptable. It attaches to a standard element on a page, allowing it to work with any web framework.

This allows us to have as many threads on a page as we desire. For instance, here are two threads displayed side-by-side.

How it works

Here’s the code that enables this functionality. We modify the urlId parameter to ensure each thread is unique. Keep in mind that we use ids, but you can pass in any DOM element queried in any way you prefer.

<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script> <div class="widgets"> <div class="widget left" id="fastcomments-widget2"></div> <div class="widget right" id="fastcomments-widget3"></div> </div>

<script> window.FastCommentsUI(document.getElementById('fastcomments-widget2'), { tenantId: 'L177BUDVvSe', urlId: window.location.href + '?cats', headerHTML: '<h1>Discuss Cats</h1>' }); </script> <script> window.FastCommentsUI(document.getElementById('fastcomments-widget3'), { tenantId: 'L177BUDVvSe', urlId: window.location.href + '?dogs', headerHTML: '<h1>Discuss Dogs</h1>' }); </script>