Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

変数のデフォルトの扱い

変数がテンプレートの至る所に頻繁に使われる場合、それが記述されるたびに変更子 default を用いると少し見苦しくなりがちです。この場合、 {assign} 関数によって変数にデフォルト値を割り当てる事でこれを改善する事ができます。

Example 18.2. デフォルト値をテンプレート変数に割り当てる


{* これをテンプレートのトップのどこかに記述します *}
{assign var='title' value=$title|default:'no title'}

{* $titleが空白ならば、それを出力する時に"no title"の値を含めます *}
{$title}

    

default 修飾子および 空白の変数の扱い も参照してください。

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 2 plus 9? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
Cheap Hosting @HostsVault
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com