how can I show “0 Notes” in tumblr when there aren't any notes?

百般思念 提交于 2020-01-23 12:13:10

问题


I tried different codes from different themes and google search. Though everything just shows a notification only if there are notes in a post.

So when there aren't notes, i wanted to show "0 notes" - How can I do that

Thanks


回答1:


From the first look solution seems to be impossible to output anything if Post has no notes due to tumblr custom themes docs, but as we shall see, the impossible is possible.

I invented trick to help you with your question.

The main idea of trick is to create special css class only if post has no notes, after it trick is using content of pseudo-elements to insert necessary text in .notes block of post.

Trick requirements: only tumblr markup and css;

Tumblr markup:

{block:Text}
<article class="{block:PostNotes}no{/block:PostNotes}nonotes">
    …
    <div class="notes">
        {block:PostNotes}
            {PostNotes}
        {/block:PostNotes}
    </div>
</article>
{/block:Text}

One line css:

article .nonotes .notes:before { content: '0 notes'; }



回答2:


I'm having the same problem. Starting to think there's no way around this :( except maybe to write your own script to get the NoteCount using the Tumblr API. Hopefully someone will be able to answer this!



来源:https://stackoverflow.com/questions/7760446/how-can-i-show-0-notes-in-tumblr-when-there-arent-any-notes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!