FC2ブログのテンプレート工房

カスタマイズが簡単な共有テンプレートを配布しています。テンプレートをカスタマイズして自分だけのオリジナルブログを作りませんか?

プラグイン説明の入力有無を判定して、表示/非表示を振り分けるフラグ

普段はあまり使われることはありませんが、プラグインにはその上と下に説明文を付けることができます。

プラグインの設定→設定[詳細]
プラグイン説明(上部)
プラグイン説明(下部)

プラグインの説明文が何も入力されないと、HTMLに無駄な空タグが生じてしまいました。

この無駄な空タグを、テンプレート変数「プラグイン説明の入力有無を判定して、表示/非表示を振り分けるフラグ」を利用して非表示にする方法を紹介します。

ただこの空タグが悪影響を及ぼすことは無いので無理に修正する必要はありません。

当サイト配布のテンプレートであれば、HTMLの下記箇所に次の赤い記述を加えてください。

standardシリーズの場合】



<!--▼▼ プラグイン カテゴリー1 ▼▼-->
<!--plugin-->
<!--plugin_first-->

<div class="menu_title" style="text-align:<%plugin_first_talign>"><%plugin_first_title></div>
<table width="100%" summary="plugin1"><tr><td class="menu_cont">

<!--plugin_first_description-->

<div style="margin: 10px 0; text-align:<%plugin_first_ialign>">
<%plugin_first_description></div>

<!--/plugin_first_description-->

<div style="margin: 10px 0; text-align:<%plugin_first_align>">
<%plugin_first_content>
</div>

<!--plugin_first_description2-->

<div style="margin: 10px 0; text-align:<%plugin_first_ialign>">
<%plugin_first_description2></div>

<!--/plugin_first_description2-->

</td></tr></table><!--/menu_cont-->
<hr class="left_width" />

<!--/plugin_first-->
<!--/plugin-->
<!--▲▲ プラグイン カテゴリー1 ▲▲-->



<!--▼▼ プラグイン カテゴリー3 ▼▼-->
<!--index_area-->
<!--plugin-->
<!--plugin_third-->

<div class="menu_title3" style="text-align:<%plugin_third_talign>"><%plugin_third_title></div>
<div class="menu_cont3">

<!--plugin_third_description-->

<div style="margin: 10px 0; text-align:<%plugin_third_ialign>">
<%plugin_third_description></div>

<!--/plugin_third_description-->

<div style="margin: 10px 0; text-align:<%plugin_third_align>">
<%plugin_third_content>
</div>

<!--plugin_third_description2-->

<div style="margin: 10px 0; text-align:<%plugin_third_ialign>">
<%plugin_third_description2></div>

<!--/plugin_third_description2-->

</div><!--/menu_cont3-->

<br />
<!--/plugin_third-->
<!--/plugin-->
<!--/index_area-->
<!--▲▲ プラグイン カテゴリー3 ▲▲-->



<!--▼▼ プラグイン カテゴリー2 ▼▼-->
<!--plugin-->
<!--plugin_second-->

<div class="menu_title" style="text-align:<%plugin_second_talign>"><%plugin_second_title></div>
<table width="100%" summary="plugin2"><tr><td class="menu_cont">

<!--plugin_second_description-->

<div style="margin: 10px 0; text-align:<%plugin_second_ialign>">
<%plugin_second_description></div>

<!--/plugin_second_description-->

<div style="margin: 10px 0; text-align:<%plugin_second_align>">
<%plugin_second_content>
</div>

<!--plugin_second_description2-->

<div style="margin: 10px 0; text-align:<%plugin_second_ialign>">
<%plugin_second_description2></div>

<!--/plugin_second_description2-->

</td></tr></table><!--/menu_cont-->
<hr class="right_width" />

<!--/plugin_second-->
<!--/plugin-->
<!--▲▲ プラグイン カテゴリー2 ▲▲-->



lightframeシリーズの場合】



<!--▼▼ プラグイン カテゴリー3 ▼▼-->
<!--index_area-->
<!--plugin-->
<!--plugin_third-->
<div class="plugin3_outline">
<div class="plugin3_title" style="text-align:<%plugin_third_talign>">
<%plugin_third_title></div>
<div class="plugin3_body">

<!--plugin_third_description-->

<div style="text-align:<%plugin_third_ialign>; margin:1px 1px;">
<%plugin_third_description></div>

<!--/plugin_third_description-->

<div style="text-align:<%plugin_third_align>">
<%plugin_third_content></div>

<!--plugin_third_description2-->

<div style="text-align:<%plugin_third_ialign>; margin:1px 1px;">
<%plugin_third_description2></div>

<!--/plugin_third_description2-->

</div><!--/plugin3_body-->
</div><!--/plugin3_outline-->
<!--/plugin_third-->
<!--/plugin-->
<!--/index_area-->
<!--▲▲ プラグイン カテゴリー3 ▲▲-->



<!--▼▼ プラグイン カテゴリー1 ▼▼-->
<!--plugin-->
<!--plugin_first-->
<div class="plugin1_outline">
<div class="plugin1_title" style="text-align:<%plugin_first_talign>"><%plugin_first_title></div>
<div class="plugin1_body" style="text-align:<%plugin_first_align>">

<!--plugin_first_description-->

<div style="text-align:<%plugin_first_ialign>; margin:1px 5px;"><%plugin_first_description></div>

<!--/plugin_first_description-->

<%plugin_first_content>

<!--plugin_first_description2-->

<div style="text-align:<%plugin_first_ialign>; margin:1px 5px;"><%plugin_first_description2></div>

<!--/plugin_first_description2-->

</div><!--/plugin1_body -->
</div><!--/plugin1_outline-->
<!--/plugin_first-->
<!--/plugin-->
<!--▲▲ プラグイン カテゴリー1 ▲▲-->



<!--▼▼ プラグイン カテゴリー2 ▼▼-->
<!--plugin-->
<!--plugin_second-->
<div class="plugin2_outline">
<div class="plugin2_title" style="text-align:<%plugin_second_talign>"><%plugin_second_title></div>
<div class="plugin2_body" style="text-align:<%plugin_second_align>">

<!--plugin_second_description-->

<div style="text-align:<%plugin_second_ialign>; margin:1px 5px;"><%plugin_second_description></div>

<!--/plugin_second_description-->

<%plugin_second_content>

<!--plugin_second_description2-->

<div style="text-align:<%plugin_second_ialign>; margin:1px 5px;"><%plugin_second_description2></div>

<!--/plugin_second_description2-->

</div><!--/plugin2_body-->
</div><!--/plugin2_outline-->
<!--/plugin_second-->
<!--/plugin-->
<!--▲▲ プラグイン カテゴリー2 ▲▲-->



これで無駄な空タグを出力しなくて済みます。

【2009/09/06 追記】この記事の修正はlightframeシリーズのver.05以降、standardシリーズのver.10以降には実装済みです。各バージョン情報はHTMLかCSSの最下部に記されています。

関連記事
[ 5755 ] おはようございます
 文法チェックをした際、<div>と</div>の間が空です になる部分かな?と思ったのですが、解釈を間違っていますか?

少し気になるのが、次回のテンプレートで実装されるのかな?という部分です。 
[ 2009/09/02 07:42 ] [ 編集 ]
[ 5784 ] > カンクネンさん
そうです。これで<div>と</div>の間が空である状態を避けれます。この修正は次回テンプレートで実装する予定です。
[ 2009/09/02 20:24 ] [ 編集 ]
コメントの投稿









管理者にだけ表示
※現在カスタマイズに関するサポートを休止中です。
表示が崩れる場合は表示が崩れる原因の調査手順をお試しください。
その他の問題はFC2ユーザーフォーラムにお問い合わせください。
トラックバック
この記事のトラックバックURL

ブログ内検索1
プロフィール

いたお

Author:いたお
更新は非常にマイペースです
現在休止中です

当サイトはリンクフリーです。

いたおの他の運営サイト
カレンダー
02 | 2024/03 | 04
- - - - - 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 - - - - - -
なんでもスクロール
このように
縦に長く伸びた
プラグインを
スクロールバーによって
一定の長さに
抑えることが
出来ます。

※スクロールさせる文字やプラグインのHTMLをここに
今日の日付入りカレンダー

02 | 2024/03 | 04
- - - - - 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 - - - - - -
ユーザータグ


△ ページトップへ戻る