如何让博主中的HTML只对管理员可见?

How to to make a piece of HTML in blogger only visible to admins?

我想在我的博客中添加一个控制面板,我找到了这个 here:

<span class='item-control blog-admin'>
<style>
.control-panel ul{z-index: 20; position: absolute; margin: 0px auto; background-color: #F6F6F6; width: 100%; }
.control-panel ul li{display: inline-block; float: left; padding: 7px 0px;}
.control-panel ul li a {color:#686868;padding: 7px 15px;border-right: 1px solid #E3E3E3;font-weight: bold;font-size: 13px;}
.control-panel a:hover {text-decoration:none; color:#FC8F44;}
</style>
<div class='control-panel'>
<ul>
<li><a href='http://www.blogger.com/home'>My Blogs</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#editor/src=sidebar&quot;' rel='nofollow'>New Post</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#editor/target=page&quot;' rel='nofollow'>New Page</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#posts&quot;' rel='nofollow'>All Posts</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#comments&quot;' rel='nofollow'>Comments</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#pageelements&quot;' rel='nofollow'>Layout</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#templatehtml&quot;' rel='nofollow'>Edit HTML</a></li>
<li><a href='#' onclick='location.reload(true); return false;'>Refresh</a></li>
<li><a href='/' target='_blank'>New Tab</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#basicsettings&quot;' rel='nofollow'>Settings</a></li>
<li><a expr:href='&quot;http://www.blogger.com/blogger.g?blogID=&quot; + data:blog.blogId + &quot;#overviewstats&quot;' rel='nofollow'>Stats</a></li>
<li><a href='http://www.blogger.com/logout.g'>Logout</a></li>
</ul>
</div>
</span>

我把它添加到博客主题的 body 下,但是小工具总是隐藏的,有没有办法让它只对管理员可见?

对于 v2 模板,由于 span 标签上存在 blog-admin class,上述代码应该可以正常工作。当管理员访问博客时,此元素 CSS 设置为 display:block 。这是通过使用 Blogger 自动添加到每个博客的以下动态 CSS 文件实现的(查明访问者是否是管理员的授权发生在幕后,我们不必担心)。

https://www.blogger.com/dyn-css/authorization.css?targetBlogID=XXXXX&amp;zx=XXXXX

在某些情况下,模板创建者通过替换 -

</head>

&lt;!-- 
</head>
--&gt; &lt;/head&gt;

在这些情况下,您必须撤消这些步骤以确保加载动态 CSS。


对于 v3 主题,默认不支持快速编辑功能。

因此,手动将动态 CSS 添加到代码中将使事情正常进行 -

<link href='https://www.blogger.com/dyn-css/authorization.css?targetBlogID=6752007275128684588&amp;zx=2f99e9cb-69f3-46cb-b0cf-85ae799dfa91' rel='stylesheet'/>
  • targetBlogID 查询参数需要设置为您的 BlogID
  • zx 查询参数是自动生成的参数(可能负责授权)