PEAK XOOPS - un-well-known(?) usage of Smarty modifier (2) in englishin japanese

Archive | RSS |
XOOPS
XOOPS : un-well-known(?) usage of Smarty modifier (2)
Poster : GIJOE on 2006-07-10 06:26:44 (11744 reads)

in englishin japanese
You should learn how Smarty calls the function written as a modifier.
In Smarty's template:
<{param1|function:param2:param3:param4}>

Compiled php code:
echo function( param1 , param2 , param3 , param4 ) ;

(This is a simplified code. The real compiled code is:
<?php echo ((is_array($_tmp=param1)) ? $this->_run_mod_handler('function', true, $_tmp, param2,param3...) : function($_tmp, param2,param3...)); ?>)

But there are functions which first parameter is not the string assigned by program. regex functions or date functions etc.

eg)
In Japan, the most used expression for date is "Y/n/j".
But, date_format as a default modifier plugin of Smarty can't do that.

You just do this.


<{"Y/n/j"|date:$news.created}>

The template will be complied like this code.

date( "Y/n/j" , $news['created'] ) ;

Perhaps, many PHP programmer can understand clearly.

Of course, it will be good weapons for designers.
You -a designer- would be better learn php functions also.
(Not only Smarty's plugins)

I recommend you to test many PHP functions via tplsadmin or altsys module.

To be continued...


Printer friendly page Send this story to a friend

Comments list

GIJOE  Posted on 2006/7/10 14:15
まあまあ。第3回をお待ちアレ
ちゃんと制限についても書きますよ。
tohokuaiki  Posted on 2006/7/10 12:26
ちょ、これは便利なんですが、多用はマズイですね。(苦笑)

Smartyの利点は「View」の機能を制限させること・・と思っているので、何でもかんでもテンプレートでできるのは{php}ブロック同様に辛いかも。

面倒とは思いつつも、プラグイン書いて登録しています・・・。あー、でもXOOPSなんかは簡単に登録できないし、しょうがないか・・・。
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!