Develop and Download Open Source Software

Recent Changes

2010-08-27
2010-03-14
2010-01-13
2010-01-12

Wiki Guide

Side Bar

<{include}>

<{include}> タグを使用して、現在のテンプレートに他のテンプレートをインクルードします。現在のテンプレートにて利用可能なあらゆる変数は、インクルードされたテンプレートでも同じく利用可能です。

  • <{include}> タグには、テンプレートリソースのパスを含んだ file 属性を必ず指定する必要があります。
  • file 属性に / から始まるパスを指定した場合はフルパスとして扱います。
  • file 属性が / から始まらない場合は相対パスとして扱います。基点となるディレクトリは template_dir で指定したディレクトリです。
  • 全ての割り当て変数の値は、インクルードされたテンプレート内で使用可能です。また、インクルードされたテンプレート内での変数の変更も <{include}> の後でインクルードしている側のテンプレート内で参照可能です。
属性名 必須 デフォルト 概要
file string Yes n/a インクルードするテンプレートファイル名
例. シンプルな <{include}> の例
<html>
<head>
  <title><{$title}></title>
</head>
<body>
<{include file='page_header.tpl'}>

<{* ここにテンプレートの本体を記述します。変数 $tpl_name
   はたとえば 'contact.tpl' などに置き換えられます。
*}>
<{include file="$tpl_name.tpl"}>

<{include file='page_footer.tpl'}>
</body>
</html>
例. さまざまな <{include}> リソースの例
<{* ファイルの絶対パス *}>
<{include file='/usr/local/include/template/header.tpl'}>

<{* windows環境の絶対パス *}>
<{include file='C:/www/pub/template/header.tpl'}>

<{* 変数名に格納された名前のテンプレートをインクルード - 例 $module = 'contacts' *}>
<{include file="$module.tpl"}>

<{php}> も参照してください。


SourceForge.JP is a Japanese version of SourceForge.net. For developments that are not related to Japan, we recommend you to use SourceForge.net.