ファンクションタグの結果を装飾する(ModifierTest01)
構成
$MT_DIR/
|__ plugins/
| |__ ModifierTest01/
| |__ config.yaml
| |__ lib/
| | |__ ModifierTest01
| | |__ Tag.pm
| |__ php/
| | |__ function.mtmdftestfunc01.php
| | |__ modifier.bold_on.php
ソース
config.yaml
# 詳細情報
id: ModifierTest01
key: ModifierTest01
name: ModifierTest01
version: 1.0
description: グローバルモディファイアテスト
author_name: プラグイン作者
author_link: http://www.example.com/about/
doc_link: http://www.example.com/docs/
# タグ情報
tags:
# ファンクションタグ
function:
MdfTestFunc01: $ModifierTest01::ModifierTest01::Tag::_hdlr_function
# グローバルモディファイア
modifier:
bold_on : $ModifierTest01::ModifierTest01::Tag::_hdlr_modifier
lib/ModifierTest01/Tag.pm
package ModifierTest01::Tag;
use strict;
# モディファイア
sub _hdlr_modifier{
# 引数
my ($text, $arg, $ctx) = @_;
# 引数を取得できない場合はそのまま抜ける
if(!$arg){
return $text;
}
# 値編集
my $res_text = "<strong>$text</strong>";
# 返却
return $res_text;
}
# ファンクションタグ
sub _hdlr_function{
# 引数を取得
my ($ctx, $args) = @_;
# 結果を返却
return "ModifierTest01";
}
1;
php/function.mtmdftestfunc01.php
<?php
function smarty_function_mtmdftestfunc01($args, &$ctx){
// 返却
return 'MdfTestFunc01 Dynamic ';
}
?>
php/modifier.bold_on.php
<?php
function smarty_modifier_bold_on($text, $arg){
// 引数をチェック
if($arg == ""){
return $text;
}
// 編集
$res_text = "<strong>$text</strong>";
// 返却
return $res_text;
}
?>
最終更新:2012年03月10日 23:34