カスタマイズ/テーマ/SmartyとDwooの違い

From Mahara Wiki
Jump to navigation Jump to search

作成中です - mits

Mahara 1.2ではテンプレートエンジンとして、Smartyの代わりにDwooを使用します。両テンプレートエンジンには多くの互換性がありますが、既存のテンプレートにおいて、変更すべき点がいくつかあります。

1.2以降、私たちは「Smarty互換」構文を使用する代わりに、さらにDwooネイティブ構文へ移行します。しかし、少なくとも1.3では下位互換性を保持します。

Cycle

In Smarty, {cycle} arguments don't need to be quoted. In Dwoo, they must be. For example, {cycle values=r0,r1} works in Smarty, but must be changed to {cycle values='r0,r1} in Dwoo.

Insert

Insert is used in Smarty to insert the return value of a function call, and skip caching. Eg {insert name="messages"} would call the php function insert_messages, and insert what it returned into the resulting template.

In Dwoo, this should be done using a native php call {insert_messages} and to bypass caching, be wrapped inside {dynamic} tags, like {dynamic}{insert_messages}{/dynamic}

Use of "data" when including templates

Both Smarty and Dwoo support including templates from within other templates, using {include}, and both support passing data between templates, using {include something='something'}. However, if you pass a variable called "data" in Dwoo, it will overwrite the existing data, because of naming collision. Therefore {include file='something.tpl' innerdata=$foo} must be used instead.

Section

In some places in Mahara 1.1, we were using {section} instead of Loops. This is really not properly compatible with Dwoo, it makes much more sense to just switch to a loop instead.