args引数を使用する(FunctionTest02)
構成
$MT_DIR/
|__ plugins/
| |__ FunctionTest02/
| |__ config.yaml
| |__ lib/
| | |__ FunctionTest02
| | |__ Tag.pm
| |__ php/
| | |__ function.mtfunctiontest02.php
ソース
config.yaml
# 詳細情報
id: FunctionTest02
key: FunctionTest02
name: FunctionTest02
version: 1.0
description: ファンクションタグテスト
author_name: プラグイン作者
author_link: http://www.example.com/about/
doc_link: http://www.example.com/docs/
# タグ情報
tags:
# ファンクションタグ
function:
FunctionTest02: $FunctionTest02::FunctionTest02::Tag::hdlr_func02
lib/FunctionTest02/Tag.pm
package FunctionTest02::Tag;
use strict;
# ファンクションタグハンドラサブルーチン
sub hdlr_func02{
# 引数を取得
my ($ctx, $args) = @_;
# 値を設定
my $num = $args->{num} || 1;
# 結果を返却
return "num=[$num]";
}
1;
php/function.mtfunctiontest02.php
<?php
function smarty_function_mtfunctiontest02($args, &$ctx){
// 初期化
$count = "";
// 引数をチェック
if(isset($args['count'])){
$count = "count={$args['count']}";
}
// 返却
return 'functiontest02 Dynamic ' . $count;
}
?>
最終更新:2012年03月10日 10:21