【问题标题】:Blogger Condition statement for search page搜索页面的 Blogger 条件语句
【发布时间】:2017-07-03 02:05:03
【问题描述】:

我正在为不同的页面使用自定义标题图片。 我有一个用于索引页的通用页眉和一个用于搜索页的页眉。

这是带有 AND 条件的代码,仅针对索引页面而不是搜索页面显示索引页面标题。

<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType!= data:blog.searchQuery'>
<div class='picheader'>
<img alt='abc' src='image url' style='width:500px;height:300px;'/>
  <br/><br/>
<div style='font-size:25px; text-shadow: 2px 1px grey;'>What we do ?</div>
Our description
</div>
</b:if>
</b:if>

<!-- Only for search page -->
<b:if cond='data:blog.searchQuery'>
<div class='picheader'>
<img alt='Search Page' src='image url' style='width:500px;height:300px;'/>
  <br/><br/>
<div style='font-size:25px; text-shadow: 2px 1px grey;'>Search Anything</div>
Looking for something...
</div>
</b:if>

但是使用此代码,索引页面还可以,但索引页面标题也与搜索页面标题一起加载。 如何解决?

【问题讨论】:

    标签: html xml blogger


    【解决方案1】:

    试试这个代码:

    <!-- If it is an Index page -->
    <b:if cond='data:blog.pageType == "index"'>
    
      <!-- If it is search page -->
      <b:if cond='data:blog.searchQuery'>
        <div class='picheader'>
          <img alt='Search Page' src='image url' style='width:500px;height:300px;'/>
            <br/><br/>
          <div style='font-size:25px; text-shadow: 2px 1px grey;'>Search Anything</div>
          Looking for something...
        </div>
    
        <!-- If it is an Index page but not Search page -->
        <b:else/>
        <div class='picheader'>
          <img alt='abc' src='image url' style='width:500px;height:300px;'/>
            <br/><br/>
          <div style='font-size:25px; text-shadow: 2px 1px grey;'>What we do ?</div>
          Our description
        </div>
      </b:if>
    
    </b:if>
    

    条件data:blog.pageType != data:blog.searchQuery 将始终返回 True(除非您搜索“索引”)。这也是它在搜索页面上显示的原因。

    【讨论】:

    • 感谢您的指正,效果很好!
    猜你喜欢
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    相关资源
    最近更新 更多