javascript - Disqus not displaying comment count - Stack Overflow

SUMMARY:I am setting up disqus to display a ment count on a page within our MVCsite. I have 'fi

SUMMARY: I am setting up disqus to display a ment count on a page within our MVC site. I have 'fixed' this feature before on a Tumblr page, so I thought I had the needed skills to do this fairly easily on this site but am failing. I have also reviewed all of Ryan's () applicable answers but have not found a solution.

I am following the directions from disqus for this:

but am having no success. My understanding is that all I need to do is:

  1. Add the script with disqus_shortname replaced within it
  2. Insert a href tag with "#disqus_thread" appended to the end of the article url

Once that is done I think the script should insert the ment count number and display it on the page -- but this isn't working for me.

In tumblr you are supposed to insert a meta tag

<meta name='text:Disqus Shortname' content='' />

but I don't believe that applies in my setting (although that didn't stop me from giving it a try).

I can only assume that I'm missing something obvious. I wonder if the localhost environment is interrupting my testing since I am using a link to a localhost page that is displaying disqus ments. I also have tested using a live disqus ment page but with the same results.

DETAILS: Currently I have tested a number of wrong things, but I believe the following is the least-wrong:

Script:

<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'My-Shortname'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
</script>

HTML:

<a href="http://localhost-link/#disqus_thread"></a>

SUMMARY: I am setting up disqus to display a ment count on a page within our MVC site. I have 'fixed' this feature before on a Tumblr page, so I thought I had the needed skills to do this fairly easily on this site but am failing. I have also reviewed all of Ryan's (https://stackoverflow./users/1370956/ryan-v) applicable answers but have not found a solution.

I am following the directions from disqus. for this:

https://help.disqus./customer/portal/articles/565624

but am having no success. My understanding is that all I need to do is:

  1. Add the script with disqus_shortname replaced within it
  2. Insert a href tag with "#disqus_thread" appended to the end of the article url

Once that is done I think the script should insert the ment count number and display it on the page -- but this isn't working for me.

In tumblr you are supposed to insert a meta tag

<meta name='text:Disqus Shortname' content='' />

but I don't believe that applies in my setting (although that didn't stop me from giving it a try).

I can only assume that I'm missing something obvious. I wonder if the localhost environment is interrupting my testing since I am using a link to a localhost page that is displaying disqus ments. I also have tested using a live disqus ment page but with the same results.

DETAILS: Currently I have tested a number of wrong things, but I believe the following is the least-wrong:

Script:

<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'My-Shortname'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus./count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
</script>

HTML:

<a href="http://localhost-link/#disqus_thread"></a>
Share Improve this question edited May 23, 2017 at 12:26 CommunityBot 11 silver badge asked Jul 21, 2015 at 18:29 Neal JonesNeal Jones 4595 silver badges19 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

So, this will probably make perfect sense to everyone who will never e to actually look at this question, it turned out that using the '#' by itself didn't work for us, instead it had to be used in conjunction with the '&' - an example:

<a href="http://localhost-link&#disqus_thread" data-disqus-identifier="12345"></a>

Also ended up using the identifier attribute, you can read about that on the same disqus article linked in my original question.

Adding '&' does seem to solve the issue.

If you're using tag helpers, you can add the & to the asp-fragment. E.g.

<a asp-area="" asp-controller="Blog" asp-action="Read" asp-route-id="@post.OriginalPost.ID" asp-fragment="&disqus_thread" data-disqus-identifier="@post.OriginalPost.ID"></a>

The issue for me turned out to be that the URL must end with a trailing slash.

For example, the following does NOT work:

<a href="/foo/bar#disqus_thread">Comments</a>

But the following does:

<a href="/foo/bar/#disqus_thread">Comments</a>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745109267a4611748.html

相关推荐

  • javascript - Disqus not displaying comment count - Stack Overflow

    SUMMARY:I am setting up disqus to display a ment count on a page within our MVCsite. I have 'fi

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信