mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-03 13:51:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			139 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			139 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<!-- EN-Revision: 1.9 Maintainer: andreas Status: ready -->
 | 
						|
<sect1 id="language.function.include.php">
 | 
						|
 <title>include_php (PHP-Code einbinden)</title>
 | 
						|
 <para>
 | 
						|
  Die Verwendung von {include_php} wird nicht mehr empfohlen, die
 | 
						|
  gleiche funktionalität kann auch mit <link
 | 
						|
  linkend="tips.componentized.templates">Template/Script
 | 
						|
  Komponenten</link> erreicht werden.
 | 
						|
 </para>
 | 
						|
 <informaltable frame="all">
 | 
						|
  <tgroup cols="5">
 | 
						|
   <colspec colname="param" align="center" />
 | 
						|
   <colspec colname="type" align="center" />
 | 
						|
   <colspec colname="required" align="center" />
 | 
						|
   <colspec colname="default" align="center" />
 | 
						|
   <colspec colname="desc" />
 | 
						|
   <thead>
 | 
						|
    <row>
 | 
						|
     <entry>Attribut Name</entry>
 | 
						|
     <entry>Typ</entry>
 | 
						|
     <entry>Erforderlich</entry>       
 | 
						|
     <entry>Standardwert</entry>
 | 
						|
     <entry>Beschreibung</entry>
 | 
						|
    </row>
 | 
						|
   </thead>
 | 
						|
   <tbody>
 | 
						|
   <row>
 | 
						|
     <entry>file</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>Ja</entry>
 | 
						|
     <entry><emphasis>n/a</emphasis></entry>
 | 
						|
     <entry>Der Name der einzubindenden PHP-Datei.</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>once</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>Nein</entry>
 | 
						|
     <entry><emphasis>true</emphasis></entry>
 | 
						|
     <entry>Definiert ob die Datei mehrmals geladen werden soll, falls sie mehrmals eingebunden wird.</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>assign</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>Nein</entry>
 | 
						|
     <entry><emphasis>n/a</emphasis></entry>
 | 
						|
     <entry>Der Name der Variable, der die Ausgabe von include_php zugewiesen wird.</entry>
 | 
						|
    </row>
 | 
						|
   </tbody>
 | 
						|
  </tgroup>
 | 
						|
 </informaltable>
 | 
						|
 <para>
 | 
						|
  Falls <link linkend="variable.security">Sicherheit</link> aktiviert
 | 
						|
  ist, muss das einzubindende Skript im <link
 | 
						|
  linkend="variable.trusted.dir">$trusted_dir</link> Pfad
 | 
						|
  liegen. {include_php} muss das Attribut 'file' übergeben werden, das
 | 
						|
  den Pfad - entweder relativ zu <link
 | 
						|
  linkend="variable.trusted.dir">$trusted_dir</link> oder absolut -
 | 
						|
  zum Skript enthält.
 | 
						|
 </para>
 | 
						|
 <para>
 | 
						|
  Normalerweise wird ein PHP-Skript nur einmal pro Aufruf geladen,
 | 
						|
  selbst wenn es mehrfach eingebunden wird. Sie können dieses
 | 
						|
  Verhalten durch die Verwendung des <emphasis>once</emphasis>
 | 
						|
  Attributs steuern. Wenn Sie 'once' auf 'false' setzen, wird die
 | 
						|
  Datei immer wenn sie eingebunden wird auch neu geladen.
 | 
						|
 </para>
 | 
						|
 <para>
 | 
						|
  Optional kann das <emphasis>assign</emphasis> Attribut übergeben
 | 
						|
  werden.  Die Ausgabe von <emphasis>include_php</emphasis> wird dann
 | 
						|
  nicht direkt eingefügt, sondern in der durch assign benannten
 | 
						|
  Template-Variable abgelegt.
 | 
						|
 </para>
 | 
						|
 <para>
 | 
						|
   Das Objekt '$smarty' kann in dem eingebundenen PHP-Script über
 | 
						|
   '$this' angesprochen werden.
 | 
						|
 </para>
 | 
						|
 <example>
 | 
						|
  <title>Funktion include_php</title>
 | 
						|
  <para>lade_nav.php</para>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
<?php
 | 
						|
 
 | 
						|
 // lade die Variablen aus einer MySQL-Datenbank und weise sie dem Template zu
 | 
						|
 require_once("MySQL.class.php");
 | 
						|
 $sql = new MySQL;
 | 
						|
 $sql->query("select * from site_nav_sections order by name",SQL_ALL);
 | 
						|
 $this->assign($sections,$sql->record);
 | 
						|
 | 
						|
?>
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   Bei folgendem index.tpl:
 | 
						|
  </para>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
{* absoluter Pfad, oder relativ zu '$trusted_dir' *}
 | 
						|
{include_php file="/pfad/zu/lade_nav.php"}
 | 
						|
 | 
						|
{foreach item=$aktuelle_section from=$sections}
 | 
						|
 <a href="{$aktuelle_section.url}">{$aktuelle_section.name}</a><br>
 | 
						|
{/foreach}
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
 </example>
 | 
						|
 <para>
 | 
						|
  Siehe auch <link
 | 
						|
  linkend="language.function.include">{include}</link>, <link
 | 
						|
  linkend="language.function.php">{php}</link>, <link
 | 
						|
  linkend="language.function.capture">{capture}</link>, <link
 | 
						|
  linkend="template.resources">Template Ressourcen</link> and <link
 | 
						|
  linkend="tips.componentized.templates">Template/Script
 | 
						|
  Komponenten</link>
 | 
						|
 </para>
 | 
						|
</sect1>
 | 
						|
<!-- Keep this comment at the end of the file
 | 
						|
Local variables:
 | 
						|
mode: sgml
 | 
						|
sgml-omittag:t
 | 
						|
sgml-shorttag:t
 | 
						|
sgml-minimize-attributes:nil
 | 
						|
sgml-always-quote-attributes:t
 | 
						|
sgml-indent-step:1
 | 
						|
sgml-indent-data:t
 | 
						|
indent-tabs-mode:nil
 | 
						|
sgml-parent-document:nil
 | 
						|
sgml-default-dtd-file:"../../../../manual.ced"
 | 
						|
sgml-exposed-tags:nil
 | 
						|
sgml-local-catalogs:nil
 | 
						|
sgml-local-ecat-files:nil
 | 
						|
End:
 | 
						|
vim600: syn=xml fen fdm=syntax fdl=2 si
 | 
						|
vim: et tw=78 syn=sgml
 | 
						|
vi: ts=1 sw=1
 | 
						|
-->
 |