<b:if cond='data:blog.url == data:blog.homepageUrl'>...</b:if>ラベル1 - TEXT 2 Widget
<b:if cond='data:blog.url == "LABEL 1 URL"'>...</b:if>
ラベル2 - TEXT 3 Widget
<b:if cond='data:blog.url == "LABEL 2 URL"'>...</b:if>
トップページのTEXT1は
<b:if cond='data:blog.pageType == "index"'>だと機能しなかったので、
<b:if cond='data:blog.url == data:blog.homepageUrl'>
但し、この「ラベルが選択されたら」という条件は、表示された最初の1ページ目だけに有効です。
2ページ目以降(1ページには20件(要検討))は URL が変わってしまうために条件に一致しなくなります。
参考
How can I show a specific text widget, when a specific label is opened?
http://www.google.com/support/forum/p/blogger/thread?fid=2d5e0604c0846ca70004a33f51d0254c&hl=en
Use label URL, like this:
<b:if cond='data:blog.url == "PUT LABEL URL HERE"'>
an example,
<b:if cond='data:blog.url == "http://sample64sample. blogspot.com/search/label/ Kustom%20Records"'>
<b:if cond='data:blog.url == "PUT LABEL URL HERE"'>
an example,
<b:if cond='data:blog.url == "http://sample64sample.
References:
| [1] | www.bloggersentral.com |
I. Conditional tag syntax
The syntax is like this:
1 | <b:if cond='PUT_CONDITION_HERE'> |
2 | </b:if> |
It is made up of a
<b:if> tag, with a cond attribute added. Condition is entered as the value of the cond attribute. Each (opening) <b:if> tag need to be closed with a closing </b:if> tag.II. List of conditional tags
Below is a list of conditional tags that target specific pages. I only list the opening tags here. Just make sure you include the closing
</b:if> tag when applying a conditional in your template.- Index (list) pages
Index pages include homepage, labels page and yearly archive page.1<b:ifcond='data:blog.pageType == "index"'> - Post (item) page
1<b:ifcond='data:blog.pageType == "item"'> - Static Page
1<b:ifcond='data:blog.pageType == "static_page"'> - Archive page
1<b:ifcond='data:blog.pageType == "archive"'> - Homepage
1<b:ifcond='data:blog.url == data:blog.homepageUrl'> - Specific page/url
1<b:ifcond='data:blog.url == "PUT_URL_HERE"'>
III. Applying conditional tags
- To apply a conditional tag to a content, simply put the content between the opening
<b:if cond…>and the closing</b:if>, like so:1<b:ifcond='data:blog.pageType == "item"'>2CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)3</b:if>In the example above, the content will only appear on post pages. - If you want to specify a alternate content (when the condition is false), you need to insert a
<b:else/>tag followed by the content, like this:1<b:ifcond='data:blog.pageType == "item"'>2CONTENT 1 (TO BE EXECUTED IF CONDITION IS TRUE)3<b:else/>4CONTENT 2 (TO BE EXECUTED IF CONDITION IS FALSE)5</b:if>You can place the conditional anywhere in your template HTML, except inside a section or inside a widget content box. The content can be a div, a section, a style tag, another conditional tag etc. - Reversing a condition A condition can be reversed simply by replacing the comparison operator from
==(is equal to) to!=(is not equal to), like so:1<b:ifcond='data:blog.pageType != "item"'>2CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)3</b:if>In the example above, the content will only appear on pages other than post pages (i.e. removed/hidden from post pages).
IV. Application examples
Below are some examples of what you can do with conditional tags:
- Display widgets on specific pages
- Applying different styling to static pages
- Adding description and keyword meta tags
参考 2
トップページにだけ表示したい。
http://www.google.com/support/forum/p/blogger/thread?tid=4892e22dee25eedc&hl=ja
レイアウトテンプレートのウィジェットタグ b:if や b:else を使うと、
閲覧ページに合わせて、ガジェット(ウィジェット)
このタグについてはこちらを確認してください。
・レイアウト用ウィジット タグ - Blogger ヘルプ
http://www.google.com/support/
ページの種類を表すデータは <data:pageType/> というデータタグで参照することができます。
ヘルプによると、この <data:pageType/> の内容は 'item'(投稿単独ページ)、'archive'(
データタグについてはこちらを確認してください。
・レイアウト データ タグ - Blogger ヘルプ
http://www.google.com/support/
これらを組み合わせて
<b:if cond='data:blog.pageType == "index"'>
(トップページに表示させたいガジェットの内容)
</b:if>
と書くと、トップページにのみ、
具体的には、「レイアウト > HTML の編集」から「ウィジェットのテンプレートを展開」
該当のガジェットのコードをみつけます。
Blogger のガジェットのコードは
<b:widget ... >
<b:includable id='main'>
...
</b:includable>
...(main 以外の includable タグ)
</b:widget>
という構造になっているので、main の includable の開始タグ・終了タグのすぐ内側に b:if の開始タグ、終了タグを挿入して
<b:widget ... >
<b:includable id='main'>
<b:if cond='data:blog.pageType == "index"'>
...
</b:if>
</b:includable>
...(main 以外の includable タグ)
</b:widget>
のようにするといいと思います。
参考3
ifによるラベルの条件分岐
> そこで、以下のようにやると あああ というラベルの記事のみ日付の非表示ができるようになったのです
質問でお示しのテンプレートタグは、
・ラベルなしだと日付を表示できない。
・「あああ」ラベルがあっても、
・「あああ」以外のラベルが複数あれば、
それで、私ならこうするかな?…というのを載せておきます。また
> たとえば、 あああ もしくは いいい という2つのラベルを非表示にしたい場合、
についても、解決してみたつもりです。
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == "nodate1"'>
<style type='text/css'>#date-header-<
<b:else/>
<b:if cond='data:label.name == "nodate2"'>
<style type='text/css'>#date-header-<
</b:if>
</b:if>
</b:loop>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header' expr:id='"date-header-&
</b:if>