如何在博客中制作一段HTML只对管理员可见?

问题描述 投票:1回答:1

我想在我的博客中添加一个控制面板,我发现这个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下添加了它,但小工具总是隐藏的,有没有办法让它只对管理员可见?

html blogger
1个回答
1
投票

对于v2模板,上面的代码应该按预期工作,因为blog-admin标记上存在span类。仅当管理员访问博客时,此元素才将CSS设置为display:block。这是使用Blogger自动添加到每个博客的以下动态CSS文件来实现的(查看访问者是否是管理员的授权发生在幕后,我们不必担心这一点)。

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

在某些情况下,模板创建者会阻止加载这个动态CSS文件(可能因为这个CSS文件永远不会被缓存,并且即使它最小化也肯定有速度优势)通过替换 -

</head>

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

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


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

quick editing not supported

因此,手动将动态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查询参数是一个自动生成的参数(可能负责授权)
© www.soinside.com 2019 - 2024. All rights reserved.