1

Version Disqus 8.x-1.0-rc3
Drupal 8.2.5

I have a page that is built up of multiple nodes using Twig Tweaks. One of the nodes has the Disqus comment field. Module runs smoothly and everything, however, the Share url is to the node/#### instead of the page.

Tried the following but to no avail:

  1. Updated the Disqus field's default identifier to [current-page:url].
  2. Overrode the node's Disque identifier manually on /node/####/edit page
  3. Tried modifying modules/disqus/js/disqus.js (w/drush cr), so that
disqus_title = document.title;
disqus_identifier = window.location.pathname + window.location.search;

I thought #2 would work above, but it still is tied to the entity's node id. The Share link always goes to /node/####.

Any assistance in this matter would be greatly appreciated.

EDIT: Just noticed that [current-page:url] does not include the search portion of the url. The URL looks like /something/node-title-text-here?page=5

2
  • I don't want to do modify disqus.js ... I know about not overwriting contrib files. Commented Jan 26, 2017 at 19:20
  • If all else fails I'm going to research how to disable the Share button. Commented Jan 26, 2017 at 21:12

1 Answer 1

0

So the solution was to add my own Javascript file and just clear the drupal settings for disqus like this:

  1. Added Javascript file to modules/custom/MYMODULE/MYMODULE.libraries.yml
disqus-overrides:
  version: VERSION
  js:
    js/disqus_overrides.js: {}
  dependencies:
    - core/drupalSettings
  1. Created a new file in modules/custom/MYMODULE/js/disqus_overrides.js

drupalSettings['disqus']['identifier'] = ''; drupalSettings['disqus']['title'] = ''; drupalSettings['disqus']['url'] = '';

  1. Then force this file to be loaded on every page load in modules/custom/MYMODULE/MYMODULE.module (this could be optimized to only load on those pages with the Disqus comment field, but I don't know how yet):

function MYMODULE_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'MYMODULE/disqus-overrides'; }

1
  • I'm not vain and will not accpt my own answer. If someone has a better solution I'll accept theirs. Commented Jan 27, 2017 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.