PHP Smarty の includeテンプレートに配列を渡せない??
イシュー
- include テンプレート側に配列を渡せないと、ブログパーツのようなものができないのだが、、
参考
- includeファイル内へ配列を渡す方法について - PHPプロ!Q&A掲示板
- PHP - Smartyで配列のキーにハイフンが使えない理由 - Qiita
- XOOPS+Smartyテンプレートテクニック 13個詰め合わせ - Qiita
- {include} | Smarty
- passing array parameters to smarty PHP template include - Stack Overflow
includeテンプレート側に配列は渡せます
- index.php
- $response['test1']のvalueは配列
$tpl = new Smarty; $tpl->assign("topPart01", $response['test1']); $tpl->display("whole.tpl");
- whole.php
- topPart01="$topPart01" とダブルクォートで囲んではダメ
{include file='top-part-01.tpl' topPart01=$topPart01 }
- part.php
<ul> {foreach from=$topPart01 item=foo} <li>{$foo.Id}</li> {/foreach} </ul>