Disqus comments went missing after changing url-appendix

I am using Disqus for comments on each product page.

Whenever I change the product page name (and its url-appendix), the Disqus comments field on that page reset itself. The comments already collected on that page are not displayed anymore.

I suspect the Disqus comments were linked to my old url-appendix.

Is there a way to let the Disqus comments be linked to something different, like some sort of self-generated unique page number?

How have you embedded the comments?

There used to be an old Disqus snippet for Kirby 1, where you could set an identifier other than the page slug, so I would suppose you can use a self-generated unique page identifier.

This is the snippet Iā€™m using now:


// set the defaults
if(!isset($disqus_shortname))  die('Please pass the disqus shortname');
if(!isset($disqus_title))      $disqus_title = $page->title();
if(!isset($disqus_developer))  $disqus_developer = false;
if(!isset($disqus_identifier)) $disqus_identifier = $page->uri();
if(!isset($disqus_url))        $disqus_url = thisURL();

$disqus_title     = addcslashes($disqus_title, "'");
$disqus_developer = ($disqus_developer) ? 'true' : 'false';

<div id="disqus_thread"></div>
<script type="text/javascript">
  var disqus_shortname  = '<?php echo $disqus_shortname ?>'; // required: replace example with your forum shortname
  var disqus_title      = '<?php echo html($disqus_title) ?>';
  var disqus_developer  = '<?php echo $disqus_developer ?>'; // developer mode
  var disqus_identifier = '<?php echo $disqus_identifier ?>';
  var disqus_url        = '<?php echo $disqus_url ?>';

  (function() {
    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>

Can you point me to the snippet where I can set an identifier other then the page slug? That would be great!

When you include the snippet, you can pass the variables as needed:

<?php snippet('disqus', array('disqus_identifier' => $page->yourIdentifier())) ?>
1 Like

Thank you! The AutoID Plugin plus your snippet suggestion should solve my problem! :smile: