目标_blank“条件”

时间:2019-12-13 07:09:09

标签: blogger target

我只需要“主页”和“联系人”看起来像“ target = _self”,其余的看起来就像“ target = _blank”(在新标签页中打开)

这是菜单代码:

<div class='art-nav desktop-nav'>
<b:section id='crosscol' maxwidgets='1' showaddelement='no'>
  <b:widget id='PageList98' locked='false' title='Pages' type='PageList' version='1'>
    <b:widget-settings>
      <b:widget-setting name='pageListJson'><![CDATA[{'home': {'href': 'https://www.henshinnews.com/', 'title': 'Home', 'position': 0}, '132343047507310766': {'href': 'https://www.henshinnews.com/p/contato_39.html', 'title': 'Contato', 'position': 1}, 'link0': {'href': 'https://www.facebook.com/henshinnews/', 'title': 'Facebook', 'position': 2}, 'link1': {'href': 'https://twitter.com/HenshinNews', 'title': 'Twitter', 'position': 3}, 'link2': {'href': 'http://feeds.feedburner.com/HenshinNews', 'title': 'Feed RSS', 'position': 4}}]]></b:widget-setting>
      <b:widget-setting name='homeTitle'>Home</b:widget-setting>
    </b:widget-settings>
    <b:includable id='main'>


<ul class='art-hmenu'>
    <b:loop values='data:links' var='link'>
        <b:if cond='data:link.isCurrentPage'>
            <li><a class='active' expr:href='data:link.href'><data:link.title/></a></li>
        <b:else/>
            <li><a expr:href='data:link.href'><data:link.title/></a></li>
        </b:if>
    </b:loop>
</ul>


        </b:includable>
  </b:widget>
</b:section>
<script>
artFixTopPagesMenu();
</script>
</div>

这是我的网站:www.henshinnews.com

1 个答案:

答案 0 :(得分:0)

您需要使用条件标签来检查链接标题并添加所需的目标属性。

尝试一下:

<div class='art-nav desktop-nav'>
  <b:section id='crosscol' maxwidgets='1' showaddelement='no'>
    <b:widget id='PageList98' locked='false' title='Pages' type='PageList' version='1'>
      <b:widget-settings>
        <b:widget-setting name='pageListJson'><![CDATA[{'home': {'href': 'https://www.henshinnews.com/', 'title': 'Home', 'position': 0}, '132343047507310766': {'href': 'https://www.henshinnews.com/p/contato_39.html', 'title': 'Contato', 'position': 1}, 'link0': {'href': 'https://www.facebook.com/henshinnews/', 'title': 'Facebook', 'position': 2}, 'link1': {'href': 'https://twitter.com/HenshinNews', 'title': 'Twitter', 'position': 3}, 'link2': {'href': 'http://feeds.feedburner.com/HenshinNews', 'title': 'Feed RSS', 'position': 4}}]]></b:widget-setting>
        <b:widget-setting name='homeTitle'>Home</b:widget-setting>
      </b:widget-settings>
      <b:includable id='main'>

        <ul class='art-hmenu'>
            <b:loop values='data:links' var='link'>
              <b:if cond='data:link.title == "Home" or data:link.title == "Contato"'>
                <b:if cond='data:link.isCurrentPage'>
                    <li><a class='active' expr:href='data:link.href' target='_self'><data:link.title/></a></li>
                <b:else/>
                    <li><a expr:href='data:link.href' target='_self'><data:link.title/></a></li>
                </b:if>
              <b:else/>
                <b:if cond='data:link.isCurrentPage'>
                    <li><a class='active' expr:href='data:link.href' target='_blank'><data:link.title/></a></li>
                <b:else/>
                    <li><a expr:href='data:link.href' target='_blank'><data:link.title/></a></li>
                </b:if>
              </b:if>
            </b:loop>
        </ul>

        </b:includable>
    </b:widget>
  </b:section>
  <script>
    artFixTopPagesMenu();
  </script>
</div>