0

I want to use this npm-module in my Ionic 3 Progressive Web App: https://www.npmjs.com/package/ngx-disqus

I have imported it to the page.module.ts like this:

import { DisqusModule } from 'ngx-disqus';
 
@NgModule({
  declarations: [
    SzenarioerstellungPage,
  ],
  imports: [
    IonicPageModule.forChild(SzenarioerstellungPage),
    DisqusModule.forRoot('my_shortname'),
  ],
  exports: [
    SzenarioerstellungPage
  ]
})
export class SzenarioerstellungPageModule {}

This is how I use it in mypage.html file:

<disqus  [identifier] = "pageId" ></disqus>

And this is how I set the pageId:

ionViewDidLoad() {
    this.szenarioProvider.getUserID().then( UID => {
      this.pageId = UID;
    });

  }

As you can see, I want to use the unique ID of the user (which he got from firebase authentification) to display a unique discus-thread on his page.

The problem is now that no matter what user gets to this page, discus only shows one and the same thread, instead of individual threads for each user.

Note: no matter what user enters the mentioned page, it always has the same URL (ionic does it like this.): http://localhost:8100/#/szenarioerstellung But I thought, that the unique [indentifier] would solve this problem.

Do you know, what I did wrong or what I need to add/ have in mind?

  • 1
    Possible duplicate of [Disqus in Angular 2 application: Showing same discussion.](https://stackoverflow.com/questions/43095097/disqus-in-angular-2-application-showing-same-discussion) – n00dl3 Jul 03 '17 at 13:10
  • I think that my question is another problem. I don't want to have multiple disqus-threads on my page. I want disqus to load the thread which belongs to the unique ID of the user who enters the page. Or did you mean, that I can't solve my problem with just one thread which changes its content depending on a unique ID? – Marcel Fieser Jul 03 '17 at 13:28
  • short answer: ngx-disqus is pretty useless build your own disqus component and call the `DISQUS.reset()` method when needed: https://help.disqus.com/customer/portal/articles/472107-using-disqus-on-ajax-sites – n00dl3 Jul 03 '17 at 13:31
  • I'll try it. Thank you. – Marcel Fieser Jul 03 '17 at 13:45
  • @n00dl3 It is not useless, you just don't know and `DISQUS.reset()` won't fix it – Murhaf Sousli Jul 03 '17 at 14:21

1 Answers1

0

DISQUS does NOT work when the # is used in the router.

for example the URL http://localhost:8100/#/szenarioerstellung is read as http://localhost:8100/, so no matter how the URL changes, it will still look the same on DISQUS side.

There are 2 solutions:

1 - Find a way to configure your router to use the hashbang #! instead of #

2 - Disable the HashLocationStrategy from the Router so it becomes like the standard URL http://localhost:8100/szenarioerstellung.

Read the requirement section in Using Disqus on AJAX sites

Murhaf Sousli
  • 12,622
  • 20
  • 119
  • 185
  • I used `import { Routes, RouterModule } from '@angular/router';` to avoid the # in the URL. But Nevertheless disqus only displayed one thread. So I think that the # cannot be the only problem. Do you have any suggestions? – Marcel Fieser Jul 04 '17 at 14:23