Nucleusのif文を拡張しよう Nucleusのif文を拡張しよう パート2
///nucleus/libs/ACTIONS.phpを改造する。 //category function _ifCategory($name = '', $value='') { global $blog, $catid; $pattern= '/^'.$catid.'\||\|'.$catid.'\||\|'.$catid.'$/'; if (($name == 'catid') && ($catid != "")){ if (preg_match($pattern,$value)=='1') { return $blog->isValidCategory($catid); } } // when no parameter is defined, just check if a category is selected if (($name != 'catname' && $name != 'catid') || ($value == '')) return $blog->isValidCategory($catid); // check category name if ($name == 'catname') { $value = $blog->getCategoryIdFromName($value); if ($value == $catid) return $blog->isValidCategory($catid); } // check category id if (($name == 'catid') && ($value == $catid)) return $blog->isValidCategory($catid); return false; } これを行なうことでif,ifnotを下記のように拡張します。 先ほどの例のif文を下記のように短縮できて見やすくなります。 if文を複数並べる際に便利です。 <%if(category,catid,1)%>表示したい内容<%endif%> <%if(category,catid,3)%>表示したい内容<%endif%> <%if(category,catid,5)%>表示したい内容<%endif%> ↓ <%if(category,catid,1|3|5)%>表示したい内容<%endif%> //item 具体的にはfunction checkCondition()の3行目に「,$itemid」を追加して「case item:」のブロックを追加しただけです。 これでアイテムIDの判定が下記の書式でできるようになります。 <%if(item,itemid,アイテムID)%>
Comment Form
このアイテムは閲覧専用です。コメントの投稿、投票はできません。
The Recent Items Of The Same Category
- 2009.12.21(Mon)NP_BlogMenu
- カスタマイズ。 ・cate...
- 2009.12.20(Sun)if文の拡張
- Nucleusのif文を拡張...
- 2009.12.19(Sat)NP_ContentsList
- カスタマイズ。 ・cate...
- 2009.12.18(Fri)Navigation Tree<%Dtree()%>
- カスタマイズ。 ・ライ...
- 2009.12.17(Thu)Nucleus Install Plugin
- Nucleusにインストール...
- 2009.12.17(Thu)jsで表示遅延解消
- BlogPeople 等のリンク...
- 2009.12.17(Thu)IE6でmin-height
- min-heightがIE6での実...
- 2009.12.13(Sun)ajaxな住所入力フォーム
- フォーム入力の際に、郵...
- 2009.12.13(Sun)フリガナ自動変換スクリプト
- フォーム入力の際に、名...
- 2009.12.12(Sat)Simplified Box Model Hack
- Simplified Box Model H...
The List Of All Tags