Tumblr: How to hide Disqus comments on pages?

As far as I know, in Tumblr there is no {block:Pages} , so everything that we add to regular posts is also added to pages, such as separation and, most importantly, comment systems.

Does anyone know about hacking or any way to remove / hide elements from pages? This is difficult because the pages use {block:Permalink} {block:Text} blocks, so I'm pretty dumb.

I just recently learned how to modify CSS using post tags using only HTML: Tumblr: How to manage CSS with message tags (UPDATE: Working method without jQuery!)

I thought maybe we can use this, the idea would be something like this:

 {block:Text} <div class="post {block:HasTags}pagefix {block:Tags}{Tag}{/...}"> ... {/block:Text} 

How it works, we by default hide any element that we don’t want to display on pages (example: Disqus) by adding the .pagefix class between {block:HasTags} in the wrapper of the div, which we can tell it to show elements on messages with tags, so items will only appear on posts, not pages, because pages do not have tags.

Two problems with this, 1) all messages MUST be marked to show hidden elements and 2) a Disqus script comment should be inserted into each type of message, and not just once before the end block {/block:Posts} .

Maybe I'm just putting Disqus in the wrong place or some other mistake, let me know what you think, I can’t find anything about it on the net. It's so dumb to not have a unique page block ...

+6
source share
3 answers

Just add your Disqus code to the date block.

 {block:Date} <!-- Disqus code --> {/block:Date} 

Since only messages have dates, the Disqus code will never be displayed on the page. This also solves the problem above where only one post violates the method.

+8
source

The trick is to wrap your Disqus code in {block:PermalinkPagination} tags as follows:

 {block:PermalinkPagination} ...disqus code... {/block:PermalinkPagination} 

Your question is a partial duplication of this on webapps.stackexhange.com, a full description can be found here .

+3
source

There is also a problem with the disqus code, in which you want the comment counter to be displayed on the first page, but not in the comments field (but there is a comment window and comments, as well as comments on the Permalink page) you should do the following:

Add #disqus_thread to the direct link of the page, for example. <a href="{Permalink}#disqus_thread"></a>

DO NOT wrap the disqus code in {block: PermalinkPagination} {/ block: PermalinkPagination}, as this will hide comments from the first page. Delete this block, if it exists, and wrap the top of the disqus script only in {block: Permalinkpage} {/ block: Permalinkpage} - the exact disqus code for Tumblr, reproduced below;

  {block:IfDisqusShortname} {block:Permalinkpage} <script type="text/javascript">var disqus_url = "{Permalink}"; var disqus_title ="{block:PostTitle}{PostTitle}{/block:PostTitle}";</script> <div id="disqus_thread"></div> <script type="text/javascript"> (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://{text:Disqus Shortname}.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript={text:Disqus Shortname}">comments powered by Disqus.</a></noscript> {/block:Permalinkpage} <!--<a href="http://disqus.com" class="dsq-brlink">{Title} comments powered by <span class="logo-disqus">Disqus</span></a>--> <script type="text/javascript"> var disqus_shortname = '{text:Disqus Shortname}'; (function () { var s = document.createElement('script'); s.async = true; s.src = 'http://{text:Disqus Shortname}.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); </script> {/block:IfDisqusShortname} </div> 
0
source

Source: https://habr.com/ru/post/889774/


All Articles