Strict Standards: Non-static method Protector::getInstance() should not be called statically in /home/suehirogari/suehirogari.com/xoops_trust_path/modules/protector/include/precheck_functions.php on line 12

Strict Standards: Non-static method XCube_Root::getSingleton() should not be called statically in /home/suehirogari/suehirogari.com/public_html/include/common.php on line 18

Deprecated: Non-static method XCube_Root::getSingleton() should not be called statically, assuming $this from incompatible context in /home/suehirogari/suehirogari.com/public_html/modules/user/preload/Primary/Primary.class.php on line 13
スマーティーを利用したif条件文で表示を変える方法 | 社内SEのウェブ制作

2012.09.27xoopsズープス

スマーティーを利用したif条件文で表示を変える方法

 まずは条件節を構成するための演算子について

 if文を構成する演算子の種類は大きく分けて、4つあります。

条件節の作り方の大きなカテゴリは4つだけです。この4つの演算子とスマーティーで取得している値を組み合わせて、if条件文を作成していきます。

 等値演算子

 == である場合
!= ではない場合

 論理演算子

 &&  かつ
||  または
!    ではない

 関係演算子

 <   左の値が右寄り小さい
>   左の値が右寄り大きい
<= 左の値が右以下
>= 左の値が右以上

 なにもない

 値があれば

xoopsのsmartyを利用したif条件文の例

まずはまとめられない複数条件節の例

<{if $row.t1_c8 == 1 }>
<img src="../../images/wf/1.gif" width="65" height="17"> 
<{elseif $row.t1_c8 == 2 }>
<img src="../../images/wf/2.gif" width="65" height="17"> 
<{elseif $row.t1_c8 == 3 }>
<img src="../../images/wf/3.gif" width="65" height="17">
<{else $row.t1_c8 == 3 }>
<img src="../../images/wf/disapprove.gif" width="65" height="17">
<{/if}>

トップページもしくはモジュール名だったら

<!-- モジュールのディレクトリ名で条件分け。トップページは空白-->
<{if $xoops_dirname == "※※"}>
A
<{else}>
B
<{/if}>

複数のモジュールで表示したい場合のif文

<{if $xoops_dirname == "1" || xoops_dirname == "2" || xoops_dirname == "3"}>

xoopsユーザ。ログインして訪問した人に見せる

<{if $xoops_isuser}>
A
<{else}>
B
<{/if}>

ユーザーだったら

<{if $xoops_isuser}>
A
<{else}>
B
<{/if}>

 

my_gmapのカテゴリーページだったら

<{if $mygmap_category }>
A
<{/if}>

※<{$mygmap_category}>のスマーティーに値がはっていたら

ユーザーネームが○○だったら

<{if $xoops_uname == "○○"}>

<{else}>

<{/if}>


このカテゴリの人気記事



  • コメント (0)
  • トラックバック (0)
  • 閲覧 (17659)

トラックバック

トラックバックpingアドレス http://www.suehirogari.com/modules/blog/tb.php/600

コメントの投稿

コメント投稿に関するルール : コメントは全て承認が必要

キーワードでサイト内を検索
人気のエントリ