【问题标题】:Remove Disqus comment box from main Tumblr page, but keep comment boxes for each post's page?从 Tumblr 主页删除 Disqus 评论框,但保留每个帖子页面的评论框?
【发布时间】:2015-04-13 22:15:42
【问题描述】:

我在 StackOverflow 或 Google 上没有找到解决我的问题的方法,所以我想问问。

我将 Disqus 添加到我的自定义主题 Tumblr 博客,但我想更改 Disqus 评论框/系统的显示位置。特别是,我不希望它出现在 Tumblr 主页面上,但我希望它出现在每个帖子的页面上。所以,如果你去我的 Tumblr 的main page 你会在底部看到 Disqus 系统——我想从那里删除它。但是,我希望 Disqus 系统出现在每个帖子的页面上:看看它是如何出现在 "Second test post" 的唯一页面底部的。

任何关于如何实现这一点的想法都将不胜感激。我尝试过的所有操作都只是从每一页中删除了 Disqus。谢谢!

我的 Tumblr 的 HTML 正文如下:

<body>
    <div id="wrapper">
        <div id="headerleft">
            <h1><a href="{BlogURL}" title="read my thoughts">Blog</a></h1>
            <ul id="menu">
                <li><a href="http://michelemasiello.com" title="home">home</a></li>
                <li>&nbsp&nbsp|&nbsp&nbsp</li>
                <li><a href="http://michelemasiello.com/projects.html" title="check out my work">projects</a></li>
                <li>&nbsp&nbsp|&nbsp&nbsp</li>
                <li><a href="mailto:msm@michelemasiello.com" title="email me">say hello</a></li>
            </ul>
        </div>
        <div id="headerright">
            <p>"Everything has been thought of before, but the problem is to think of it again."<br>&#8212;&nbspJohann Wolfgang von Goethe</p>
        </div>
        <div id="recentposts">
            <ul id="postlist"></ul>
        </div>

        {block:Posts}

            {block:Text}
            <div class="post">
                {block:Title}
                    <h2><a href="{Permalink}">{Title}</a></h2>
                {/block:Title}
                {Body}
                <br>
                <ul class="like-reblog">
                  <li>{LikeButton color="black"}</li>
                  <li>{ReblogButton color="black"}</li>
                  <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                  <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                  <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                  <script type="text/javascript">
                    var disqus_shortname = '{text:Disqus Shortname}';
                    (function () {
                        var s = document.createElement('script'); s.async = true;
                        s.type = 'text/javascript';
                        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                    }());
                </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {/block:Text}

            {block:Photo} 
            <div class="post">  
                <img src="{PhotoURL-500}">
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                    <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Photo}

            {block:Quote}
            <div class="post">
                {Quote}
                {block:Source}<br>&mdash;{Source}{/block:Source}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Quote}

            {block:Link}
            <div class="post">
                <a href="{URL}" {Target}>{Name}</a>
                {block:Description}{Description}{/block:Description}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Link}

            {block:Chat}
            <div class="post">
                {block:Title}{Title}{/block:Title}
                <table>
                    {block:Lines}
                    <tr>
                        <th>{block:Label}{Label}{/block:Label}</th>
                        <td>{Line}</td>
                    </tr>
                    {/block:Lines}
                </table>
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Chat}

            {block:Audio}
            <div class="post">
                {AudioPlayer}
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Audio}

            {block:Video}
            <div class="post">
                {Video-500}
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Video}

        {/block:Posts}


        {block:IfDisqusShortname}
        <div id="disqus_thread"></div>
        <script type="text/javascript">
            /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
            var disqus_shortname = '{text:Disqus Shortname}'; // Required - Enter shortname in Tumblr Theme Options
            var disqus_url = '{Permalink}'; 

            /* * * DON'T EDIT BELOW THIS LINE * * */
            (function() {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = '//' + 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">comments powered by Disqus.</a></noscript>
        <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
        {/block:IfDisqusShortname}


        {block:Pagination}
        <div class="pagenav">
            {block:PreviousPage}<a href="{PreviousPage}">Previous</a>{/block:PreviousPage}
            {block:NextPage}<a href="{NextPage}">Next</a>{/block:NextPage}
        </div>
        {/block:Pagination}



    </div>
</body>

【问题讨论】:

    标签: html blogs tumblr disqus


    【解决方案1】:

    {block:IfDisqusShortname} 之前添加{block:PermalinkPage} 并在{/block:IfDisqusShortname} 之后添加{/block:PermalinkPage},如下所示:

    {block:PermalinkPage}
        {block:IfDisqusShortname}
            //Disqus' code
        {/block:IfDisqusShortname}
    {/block:PermalinkPage}
    

    【讨论】:

    • 完美运行!谢谢!
    猜你喜欢
    • 1970-01-01
    • 2011-12-18
    • 2014-03-28
    • 2019-09-01
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 2012-03-09
    相关资源
    最近更新 更多