LoginSignup
0
4

More than 5 years have passed since last update.

smartyメモ

Last updated at Posted at 2016-04-27

すぐ忘れて調べるリスト。

数値を3桁毎にカンマ区切りにする

smarty
{$number|number_format}

smartyでのfor文

たまにやるときある。

smarty
{section name=hoge start=0 loop=10}
  {$smarty.section.hoge.index}
{/section}

smartyでのcount

配列内を数える時とか。

smarty
{$array|count}

smartyの日付整形

phpと地味に違って罠。

smarty
{$data|date_format:'%Y-%m-%d %H:%M:%S'}
/* 表示結果 */
2016-01-01 00:00:00

指定数で文字を切り捨てる

記事一覧とかに便利。

smarty
// 200文字で切り捨てる
{$text|truncate:200}

// 200文字で切り捨て、最後に'...'を付ける
{$text|truncate:200:'...'} 

改行を表示。

与えられた変数内の全ての改行文字\nをhtmlの<br />タグに変換。
textareaの値を表示する時とかに。

{$text|nl2br}

随時更新。

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4