doublesecretagency / craft-upvote

Upvote plugin for Craft CMS
Other
16 stars 6 forks source link

Plugin working everywhere except one template #28

Closed webtrend closed 4 years ago

webtrend commented 4 years ago

This plugin works everywhere except one location in one of my craft templates and I have spent a lot of time on this without any success. So I am asking the question in the hope that someone might be able to resolve this issue for me. My relevant template code looks like this

{% set articles = craft.entries.section('helparticles').level(2).orderBy('dateUpdated desc').relatedTo(category).limit(15) %}
{% for article in articles.all() %}
       <span class="upvote"><i class="fal fa-thumbs-up fa-fw" data-toggle="tooltip" title="Upvotes"></i> {{ craft.upvote.tally(article.id) }}</span>
{% endfor %}

It is returning &nbsp; instead of the actual upvote tally The article.id is returning the correct elementId (I have checked)

I have used similar code in several other templates and I am not seeing this issue anywhere and therefore I am perplexed. Any help will be appreciated. Thanks.

lindseydiloreto commented 4 years ago

Hi @webtrend,

It's hard to say what's going on here. Feel free to DM me on Craft Discord (@lindseydiloreto) and we can try to troubleshoot it together in real-time.

I'm going to guess that you have some JavaScript on your page, which is preventing the tally from properly updating after the page has finished loading. It's designed to load an empty container, then immediately populate it with the real value. This helps circumvent any caching issues. But if some other JS error is tripping everything up, then perhaps the container never gets a chance to be properly populated.

For more information, check out the docs on controlling the output format...