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